Search code examples
linuxperlasciikeycode

How can I translate Linux keycodes from /dev/input/event* to ASCII in Perl?


I'm writing a Perl script that reads data from the infamous /dev/input/event* and I didn't find a way to translate the key codes generated by the kernel into ASCII.

I'm talking about the linux key codes in this table here and I can't seem to find something that would help me translate them without hardcoding an array into the script. Am I missing something?

I'd like to skip the array part because it doesn't seem to be a good practice, so any idea? :)


Solution

  • It's basically a map problem. You have to take a keycode and lookup its ASCII equivalent. What about the "array part" do you think is not a good practice?

    I didn't see a module for this on CPAN, but that means that you have a chance to be the first to upload it. :)