[vox-tech] convert keycodes to characters

Bryan Richter btrichter at ucdavis.edu
Tue Nov 30 00:27:50 PST 2004


Hi,

As an academic endeavour, I am writing a program that will make data regarding
keyboard usage (key frequency, etc). So far I've got a program that can read
keyboard events via /dev/input/event0, but that gets me as far as keycodes and
event types such as 'key release' or 'key press'. What I would like next is to
convert the codes into characters, so different keymaps don't create spurious
data. That is, if I press the key labeled 'd', I want the code 32 to be
converted to a 'd' if using qwerty, xor to a 'e' if using Dvorak (32 is the code
generated by the key labeled 'd', regardless if typing on the console or in X
and regardless of console keymap and X keymap). 

Ideally I could handle both console and X, but as I'm mainly in X the following
questions will suffice:

1. Can I programmatically figure out what the X keymap is?
2. Can I programmatically use the X keymap to convert keycodes to characters?

The corresponding questions re: the console would also be nifty. :)

-Bryan

p.s. I keep thinking it myself, so I assume some of you will think it: Yes, this
sounds like a keylogger. I promise, I'm not evil. 0:) 

-- 
Bryan Richter
UCDTT President
UC Davis Undergrad, Physics Dept.
-
A PGP signature is (probably) attached to this email. 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 307 bytes
Desc: Digital signature
Url : http://ns1.livepenguin.com/pipermail/vox-tech/attachments/20041130/d70bce51/attachment.bin


More information about the vox-tech mailing list