Keyboard accessibility in web applications

by gowtham 2010-02-09 11:17:59

* keyCode gives the code of the key for a specific event. For example, the key code for Enter is 13, or 17 for Control. Some keys, mostly the alpha-numeric ones, have the same key code as the character Unicode decimal value. For example, the key P has the key code 80, which is the same as the Unicode decimal for the "P" capital letter.
* charCode is only provided by Firefox (Gecko), Safari (Webkit) and Google Chrome (Webkit) when the key generates a character. It holds the Unicode decimal for that character.
* which is arbitrarily available in most browsers, except Internet Explorer.
* keyIdentifier is the new property defined by the DOM 3 Events specification. This property is only available for the keydown and keyup events, in Webkit and Konqueror 4. The values it holds are either key names like Enter, PageDown etc., or the the Unicode character generated by the key event, using the literal notation "U+XXXX". If you press the P key, then the keyIdentifier value is "U+0050".

So this is the big picture - you are already getting an idea of how difficult is to identify a key from a keyboard event. In short, the browser differences you need to be aware of are as follows:

* The keyCode property holds the code of the key only during the keydown and keyup events in most browsers. In the keypress event, this property actually holds the character Unicode decimal value. For example, if you press the key P without holding the Shift key down, then keyCode is 80 in the keydown and the keyup events. In the keypress event the property value is 112 - the Unicode decimal for the "p" character.
* Since not all browsers give the charCode property, in the keypress event you cannot easily determine the difference between a key code and a character code. Therefore, you need to remember the key code from the keydown event.
* Webkit does not always provide the correct value for the keyIdentifier property. For some keys, the value is "U+0000" instead of "Unidentified" as the specification says it should be when the key is not recognized.
* Konqueror 4 does not use the "U+XXXX" notation in the keyIdentifier property. Instead, it gives you the character directly, as-is.

Tagged in:

995
like
0
dislike
0
mail
flag

You must LOGIN to add comments