2

I am writing a shell script that uses xinput, and I would like to get a human-readable description of what the user has typed using the keycode from xinput.

For example, A generates 38. Ctrl is 37.

How can I get those key names from the codes?

2
  • Start with man -k keycode?
    – waltinator
    Jun 27, 2016 at 15:57
  • 2
    That's close, but as far as I can tell those only return the keyboard mappings which isn't a very good description of what the keys actually are. Also, most of them don't work: Couldn't get a file descriptor referring to the console. Jun 28, 2016 at 14:07

1 Answer 1

1

If your on Xorg use xev: It opens a window that catches all events (incl. keystrokes) and displays the results, e.g.:

enter code KeyPress event, serial 40, synthetic NO, window 0x5400001,
root 0xc2, subw 0x5400002, time 29136757, (50,54), root:(1311,78),
state 0x1, keycode 38 (keysym 0x41, A), same_screen YES,
XLookupString gives 1 bytes: (41) "A"
XmbLookupString gives 1 bytes: (41) "A"
XFilterEvent returns: False

Maybe have a look at https://wiki.archlinux.org/index.php/extra_keyboard_keys for more details.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .