Sys.UI.DomEvent keyCode Field

Gets the key code of the key that raised the keyUp or keyDown event.

var keyCode = domEventVar.keyCode;

Return Value

An integer value that represents the key code of the key that was pressed to raise the keyUp or keyDown event.

Remarks

Use the keyCode field to get the key code of the key that was pressed to raise a keyUp or keyDown event. In the case of key combinations such as CTRL+Z, the key code reflects each key that raised the keyUp or keyDown event. The keyUp and keyDown events are raised for every key, which includes modifier keys such as ALT, CTRL, and SHIFT.

To get a character code that represents a key combination, use the Sys.UI.DomEvent charCode field instead. The charCode field returns the character code of a key that raised the keyPress event, which provides a single character code that identifies key combinations. The keyPress event is not raised for single modifier keys such as ALT, CTRL, and SHIFT.

See Also

Reference

Sys.UI.DomEvent Class

Other Resources

Language Reference