xev should work
Odd, my xev gives a KeyPress and KeyRelease event for alt (and for the Windows key, here called "super"):
KeyPress event, serial 40, synthetic NO, window 0xae00001,
root 0x2ca, subw 0x0, time 595467354, (98,77), root:(102,443),
state 0x10, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 40, synthetic NO, window 0xae00001,
root 0x2ca, subw 0x0, time 595467453, (98,77), root:(102,443),
state 0x18, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
And the right-hand one:
KeyPress event, serial 40, synthetic NO, window 0xae00001,
root 0x2ca, subw 0x0, time 595572876, (75,33), root:(79,399),
state 0x10, keycode 108 (keysym 0xffea, Alt_R), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 40, synthetic NO, window 0xae00001,
root 0x2ca, subw 0x0, time 595572972, (75,33), root:(79,399),
state 0x18, keycode 108 (keysym 0xffea, Alt_R), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
I can see two possibilities:
- Something else is completely eating the keypress, or defocusing the window upon you pressing alt. Try running xev in an otherwise empty X server (e.g., just run
xinit -- :1
, which should get you a X server with only an xterm—there won't even be a window manager running. Exiting the xterm will close the session).
- You just missed the two events in the bulk that xev spews out.
An easy way, if you know the key name
Another possibility: just get the keycodes from xmodmap:
anthony@Zia:~$ xmodmap -pk | grep -i alt
64 0xffe9 (Alt_L) 0xffe7 (Meta_L) 0xffe9 (Alt_L) 0xffe7 (Meta_L)
108 0xffea (Alt_R) 0xffe8 (Meta_R) 0xffea (Alt_R) 0xffe8 (Meta_R)
204 0x0000 (NoSymbol) 0xffe9 (Alt_L) 0x0000 (NoSymbol) 0xffe9 (Alt_L)
anthony@Zia:~$ xmodmap -pk | grep -i super
133 0xffeb (Super_L) 0x0000 (NoSymbol) 0xffeb (Super_L)
134 0xffec (Super_R) 0x0000 (NoSymbol) 0xffec (Super_R)
206 0x0000 (NoSymbol) 0xffeb (Super_L) 0x0000 (NoSymbol) 0xffeb (Super_L)
There is the 64 and 108 again. xmodmap -pm
will show you just the modifier map, which also gives you the numbers (though, this time, in hex).