$keyval returns the key CODE, if you want the key CHAR you should be using $keychar. There's a lot more collisions for other non-text keys like PageUp PageDn etc. F10 has same the same $keyval as 'x', but returns $keychar as $null instead of as 'x'.

Also, mIRC maps $keycode 127 to Ctrl+Backspace (delete word left) with $keychar also being $chr(127). Search the forum for the /sendkeys alias, and you'll find that this behaves like delete-word-left:

Code:
//sendkeys abcd DeletesThisWord $+ $chr(127) efgh