Lua key input support was only recently added to 4.1. You need to create a keyboard event handler to check key pressed/released & special keys.
http://wiki.visionaire-tracker.net/wiki/RegisterEventHandler -- check example 3.
Keydown will constantly trigger code if character == x
keyup will only trigger once on release
textkeyinput is for unicode characters...
there are also some special keys that have their own eKey access, which I will add to the _(CMS) page version I will get around to typing up at some point.