Keyboard handling in Javascript events gives a whole new meaning to "impossible". It turns out that there is simply no reliable way to do this and still have your code work across the board.
The main problem here turns out to be Opera. Opera, in their ultimate wisdom, have decided that in the keypress event they will give you the Keyboard code for function keys, and Character code for all other keys. The problem is that they give you this code in the same variable in the event object.
The problem comes from the fact that the keyboard code and the character code can, and often do, overlap each other. For example, the character code for the period character is 46. It just so happens that the keyboard code for the delete key is also 46. Having compared the event object that is passed into the keypress event when the period and the delete key are pressed, the event objects are identical. There is not a single way to tell the difference between those two keys in that event!
As it happens, the reason I was trying to do this was to have a text field that only allows certain keys to be pressed. Period wasn't one of the keys, but I did want all the function keys to work (arrows, delete, home, end, etc). Another "feature" of Opera is that these keys can not be cancelled. As such, if I think it might be a period I can try and cancel it, and if it's a period it's cancelled and if it's a delete then it's not.