You are not logged in.

#1 2014-06-13 18:58:13

skyer
Member
Registered: 2012-06-25
Posts: 56

keyboard shortcut to generate keypress

I want to set up a keyboard shortcut to generate a single key press.

[BACKGROUND]
I have a keyboard that has the F section and multimedia section joined. The multimedia keys are default, to generate F key press, I need to do Fn+F. I'm usually fine with the multimedia keys, but I use F5 and F2 often - so I'd like to get those two to be the default ones.

The problem is, the keyboard doesn't generate a simple keycode after pressing the F button by itself. Instead, it generates a keycode with multiple modifiers active.

So I need to add a new 'rule': keycode+multiple modifiers ---> keysym

[MY ATTEMPS]

1) create my own keymap. However, loadkeys -m doesn't output anything for me, and I don't know where to start.
2) use xmodmap, and then run it after each login. However, it seems the xmodmap simply doesn't support the type of rule I need. The kernel translation table is full of such rules, still can't find a way to add one. I figure that if I were to consider Super_L and Control_L as mere keycodes, that could be a problem, but they're mapped to modifiers.
3) use i3 shortcuts - no idea how to 'emit' a keypress event. 

[SELECTIVE XEV OUTPUT]
a single F5 key press

KeyPress event, serial 32, synthetic NO, window 0x1e00001,
    root 0x9c, subw 0x0, time 22408907, (5,235), root:(1289,259),
    state 0x10, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 32, synthetic NO, window 0x1e00001,
    root 0x9c, subw 0x0, time 22408907, (5,235), root:(1289,259),
    state 0x14, keycode 133 (keysym 0xffeb, Super_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 32, synthetic NO, window 0x1e00001,
    root 0x9c, subw 0x0, time 22408907, (5,235), root:(1289,259),
    state 0x54, keycode 22 (keysym 0xff08, BackSpace), same_screen YES,
    XLookupString gives 1 bytes: (08) "
    XmbLookupString gives 1 bytes: (08) "
    XFilterEvent returns: False

KeyRelease event, serial 32, synthetic NO, window 0x1e00001,
    root 0x9c, subw 0x0, time 22408915, (5,235), root:(1289,259),
    state 0x54, keycode 22 (keysym 0xff08, BackSpace), same_screen YES,
    XLookupString gives 1 bytes: (08) "
    XFilterEvent returns: False

KeyRelease event, serial 32, synthetic NO, window 0x1e00001,
    root 0x9c, subw 0x0, time 22408923, (5,235), root:(1289,259),
    state 0x54, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 32, synthetic NO, window 0x1e00001,
    root 0x9c, subw 0x0, time 22408923, (5,235), root:(1289,259),
    state 0x50, keycode 133 (keysym 0xffeb, Super_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

Fn+F5

KeyPress event, serial 32, synthetic NO, window 0x2000001,
    root 0x9c, subw 0x0, time 23828524, (220,806), root:(1504,830),
    state 0x10, keycode 71 (keysym 0xffc2, F5), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 32, synthetic NO, window 0x2000001,
    root 0x9c, subw 0x0, time 23828620, (220,806), root:(1504,830),
    state 0x10, keycode 71 (keysym 0xffc2, F5), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

Thanks for any help.

Offline

#2 2014-06-13 23:47:55

fungle
Member
Registered: 2014-05-01
Posts: 81

Re: keyboard shortcut to generate keypress

Offline

#3 2014-06-18 18:50:32

skyer
Member
Registered: 2012-06-25
Posts: 56

Re: keyboard shortcut to generate keypress

I'm sorry for late response,
no I haven't XKB has always been one big mess of mystery for me.

Would you mind sketching a suitable rule?

Thanks.

Offline

#4 2014-07-16 17:00:22

skyer
Member
Registered: 2012-06-25
Posts: 56

Re: keyboard shortcut to generate keypress

For people who read this in future:
Check out "xdotool" - X utility that can generate keypress.

Last edited by skyer (2014-07-16 17:02:17)

Offline

Board footer

Powered by FluxBB