Bash – What does this output from xev mean

bashkeyboardkeyboard shortcutslinuxterminal

I'm interested in remapping some keys on my keyboard. In particular, I want to hold down the Function key, press the F1 key, and have this trigger a script. I know that xev is useful for figuring out what keycode is associated with a keypress. For example, when I press the x key, I get:

KeyPress event, serial 41, synthetic NO, window 0x2600001,
    root 0xae, subw 0x0, time 1597243, (-190,43), root:(910,336),
    state 0x0, keycode 53 (keysym 0x78, x), same_screen YES,
    XLookupString gives 1 bytes: (78) "x"
    XmbLookupString gives 1 bytes: (78) "x"
    XFilterEvent returns: False

KeyRelease event, serial 41, synthetic NO, window 0x2600001,
    root 0xae, subw 0x0, time 1597363, (-190,43), root:(910,336),
    state 0x0, keycode 53 (keysym 0x78, x), same_screen YES,
    XLookupString gives 1 bytes: (78) "x"
    XFilterEvent returns: False

This makes sense to me.

However, when I press Function-F1, I don't understand what happens. Why does pressing Function-F1 seem to behave as if I've also held the Windows button, and typed the letter l?

xev output when I press Function-F1:

KeyPress event, serial 41, synthetic NO, window 0x2600001,
    root 0xae, subw 0x0, time 1735349, (-157,221), root:(943,514),
    state 0x0, keycode 133 (keysym 0xffeb, Super_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 41, synthetic NO, window 0x2600001,
    root 0xae, subw 0x0, time 1735350, (-157,221), root:(943,514),
    state 0x40, keycode 46 (keysym 0x6c, l), same_screen YES,
    XLookupString gives 1 bytes: (6c) "l"
    XmbLookupString gives 1 bytes: (6c) "l"
    XFilterEvent returns: False

MappingNotify event, serial 41, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 8, count 248

KeyPress event, serial 41, synthetic NO, window 0x2600001,
    root 0xae, subw 0x0, time 1735356, (-157,221), root:(943,514),
    state 0x40, keycode 160 (keysym 0x1008ff2d, XF86ScreenSaver), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 41, synthetic NO, window 0x2600001,
    root 0xae, subw 0x0, time 1735357, (-157,221), root:(943,514),
    state 0x40, keycode 160 (keysym 0x1008ff2d, XF86ScreenSaver), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

MappingNotify event, serial 42, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 8, count 248

KeyRelease event, serial 42, synthetic NO, window 0x2600001,
    root 0xae, subw 0x0, time 1735463, (-157,221), root:(943,514),
    state 0x40, keycode 46 (keysym 0x6c, l), same_screen YES,
    XLookupString gives 1 bytes: (6c) "l"
    XFilterEvent returns: False

KeyRelease event, serial 43, synthetic NO, window 0x2600001,
    root 0xae, subw 0x0, time 1735470, (-157,221), root:(943,514),
    state 0x40, keycode 133 (keysym 0xffeb, Super_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

When I press Function-F1 with a text window focused, it types the letter l.

Background information: Running Lubuntu 11.10 on a Toshiba r835. Happy to provide any further details that might be helpful.

EDIT:

For comparison, when I type Function-F12, I get:

KeyPress event, serial 41, synthetic NO, window 0x2200001,
    root 0xae, subw 0x0, time 8369184, (-620,473), root:(480,766),
    state 0x0, keycode 78 (keysym 0xff14, Scroll_Lock), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 41, synthetic NO, window 0x2200001,
    root 0xae, subw 0x0, time 8369344, (-620,473), root:(480,766),
    state 0x0, keycode 78 (keysym 0xff14, Scroll_Lock), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

I wanted to check if there's something special about the F1-F12 keys, but it looks like at least some of them work how I expect.

Best Answer

When you say Function-F1, I assume you mean pressing that funny little Fn key in the corner of a laptop followed by the F1 key at the top left of the keyboard. And that your trying to map one of the extra keys like Sleep that some laptop keyboards have. It looks like that key is literally pressing multiple keys for you. First I see Win+L as one combo. On Windows, this shortcut locks the screen, but does not start the screensaver. Next, I see a mapping for XF86ScreenSaver which might mean that X is seeing some kind of sleep keycode. I'm guessing that that key on your laptop keyboard is physically sending out those three keycodes of Win + L + Sleep as a convenience for Windows users to quickly lock the screen and activate the screensaver. I'm not sure of a good way to filter those out. The Fn key on keyboards normally is not seen by the Linux Kernel. Instead, it changes which codes the keyboard tells the kernel. When I was trying to use a USB RF PowerPoint remote with OOo on Linux, I discovered that the button to start/stop the presentation was just a lame control to send out alternating F5 and ESC key codes. Other buttons were just as lame like sending out b to blank the screen.

Related Question