The goog.events.KeyCodes Enum

goog.events.KeyCodes

Key codes for common characters. This list is not localized and therefore some of the key codes are not correct for non US keyboard layouts. See comments below.

@enum
{number}

.A

.ALT

.APOSTROPHE

.B

.BACKSLASH

.BACKSPACE

.C

.CAPS_LOCK

.CLOSE_SQUARE_BRACKET

.COMMA

.CONTEXT_MENU

.CTRL

.D

.DASH

.DELETE

.DOWN

.E

.EIGHT

.END

.ENTER

.EQUALS

.ESC

.F

.F1

.F10

.F11

.F12

.F2

.F3

.F4

.F5

.F6

.F7

.F8

.F9

.FF_EQUALS

.FF_SEMICOLON

.FIRST_MEDIA_KEY

.FIVE

.FOUR

.G

.H

.HOME

.I

.INSERT

.J

.K

.L

.LAST_MEDIA_KEY

.LEFT

.M

.MAC_ENTER

.MAC_FF_META

.META

.N

.NINE

.NUMLOCK

.NUM_CENTER

.NUM_DIVISION

.NUM_EIGHT

.NUM_FIVE

.NUM_FOUR

.NUM_MINUS

.NUM_MULTIPLY

.NUM_NINE

.NUM_ONE

.NUM_PERIOD

.NUM_PLUS

.NUM_SEVEN

.NUM_SIX

.NUM_THREE

.NUM_TWO

.NUM_ZERO

.O

.ONE

.OPEN_SQUARE_BRACKET

.P

.PAGE_DOWN

.PAGE_UP

.PAUSE

.PERIOD

.PHANTOM

.Q

.QUESTION_MARK

.R

.S

.SCROLL_LOCK

.SEMICOLON

.SEVEN

.SHIFT

.SINGLE_QUOTE

.SIX

.SLASH

.SPACE

.T

.TAB

.THREE

.TILDE

.TWO

.U

.UP

.V

.W

.WIN_IME

.WIN_KEY

.WIN_KEY_FF_LINUX

.WIN_KEY_RIGHT

.X

.Y

.Z

.ZERO

.firesKeyPressEvent(keyCode, opt_heldKeyCode, opt_shiftKey, opt_ctrlKey, opt_altKey)

Returns true if the key fires a keypress event in the current browser. Accoridng to MSDN [1] IE only fires keypress events for the following keys: - Letters: A - Z (uppercase and lowercase) - Numerals: 0 - 9 - Symbols: ! @ # $ % ^ & * ( ) _ - + = < [ ] { } , . / ? \ | ' ` " ~ - System: ESC, SPACEBAR, ENTER That's not entirely correct though, for instance there's no distinction between upper and lower case letters. [1] http://msdn2.microsoft.com/en-us/library/ms536939(VS.85).aspx) Safari is similar to IE, but does not fire keypress for ESC. Additionally, IE6 does not fire keydown or keypress events for letters when the control or alt keys are held down and the shift key is not. IE7 does fire keydown in these cases, though, but not keypress.

keyCode {number}
A key code.
opt_heldKeyCode {number=}
Key code of a currently-held key.
opt_shiftKey {boolean=}
Whether the shift key is held down.
opt_ctrlKey {boolean=}
Whether the control key is held down.
opt_altKey {boolean=}
Whether the alt key is held down.
returns {boolean}
Whether it's a key that fires a keypress event.

.isCharacterKey(keyCode)

Returns true if the key produces a character. This does not cover characters on non-US keyboards (Russian, Hebrew, etc.).

keyCode {number}
A key code.
returns {boolean}
Whether it's a character key.

.isTextModifyingKeyEvent(e)

Returns true if the event contains a text modifying key.

e {goog.events.BrowserEvent}
A key event.
returns {boolean}
Whether it's a text modifying key.

.normalizeGeckoKeyCode(keyCode)

Normalizes key codes from their Gecko-specific value to the general one.

keyCode {number}
The native key code.
returns {number}
The normalized key code.