Package com.google.gwt.event.dom.client
Class KeyCodes
java.lang.Object
com.google.gwt.event.dom.client.KeyCodes
Contains the native key codes previously defined in
KeyboardListener
. When converting
keyboard listener instances, developers can use the following static import
to access these constants:
import static com.google.gwt.event.dom.client.KeyCodes.*;These constants are defined with an int data type in order to be compatible with the constants defined in
KeyboardListener
.-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Key code for Astatic final int
Alt key code.static final int
Key code for Bstatic final int
Backspace key code.static final int
Key code for Cstatic final int
Key code for caps lock keystatic final int
Key code for close square bracket, ].static final int
Key code for context menu key.static final int
Control key code.static final int
Key code for Dstatic final int
Delete key code (also numeric keypad delete).static final int
Down arrow code (Also numeric keypad down).static final int
Key code for Estatic final int
Key code number 8static final int
End key code (Also numeric keypad south west).static final int
Enter key code.static final int
Escape key code.static final int
Key code for Fstatic final int
Key code for F1static final int
Key code for F10static final int
Key code for F11static final int
Key code for F12static final int
Key code for F2static final int
Key code for F3static final int
Key code for F4static final int
Key code for F5static final int
Key code for F6static final int
Key code for F7static final int
Key code for F8static final int
Key code for F9static final int
Key code for first OS specific media key (like volume).static final int
Key code number 5static final int
Key code number 4static final int
Key code for Gstatic final int
Key code for Hstatic final int
Home key code (Also numeric keypad north west).static final int
Key code for Istatic final int
Key code for insert key (Also numeric keyboard insert).static final int
Key code for Jstatic final int
Key code for Kstatic final int
Key code for Lstatic final int
Key code for last OS specific media key (like volume).static final int
Left key code (Also numeric keypad west).static final int
Key code for Mstatic final int
Key code for Mac enter keystatic final int
Key code forKEY_WIN_KEY_LEFT_META
that Firefox fires for the meta key.static final int
Key code for Nstatic final int
Key code number 9static final int
Key code for insert key (Also num lock on FF,Safari Mac).static final int
Key code for division on numeric keyboardstatic final int
Key code for number 8 on numeric keyboardstatic final int
Key code for number 5 on numeric keyboardstatic final int
Key code for number 4 on numeric keyboardstatic final int
Key code for minus on numeric keyboardstatic final int
Key code for multiply on numeric keyboardstatic final int
Key code for number 9 on numeric keyboardstatic final int
Key code for number 1 on numeric keyboardstatic final int
Key code for period on numeric keyboardstatic final int
Key code for plus on numeric keyboardstatic final int
Key code for number 7 on numeric keyboardstatic final int
Key code for number 6 on numeric keyboardstatic final int
Key code for number 3 on numeric keyboardstatic final int
Key code for number 2 on numeric keyboardstatic final int
Key code for number 0 on numeric keyboardstatic final int
Key code for num lock.static final int
Key code for Ostatic final int
Key code number 1static final int
Key code for open square bracket, [.static final int
Key code for Pstatic final int
Page down key code (Also numeric keypad south east).static final int
Page up key code (Also numeric keypad north east).static final int
Key code for pause keystatic final int
Key code for print keystatic final int
Key code for Qstatic final int
Key code for Rstatic final int
Right arrow key code (Also numeric keypad east).static final int
Key code for Sstatic final int
Key code for scroll lock.static final int
Key code number 7static final int
Shift key code.static final int
Key code number 6static final int
Key code for spacestatic final int
Key code for Tstatic final int
Tab key code.static final int
Key code number 3static final int
Key code number 2static final int
Key code for Ustatic final int
Up Arrow key code (Also numeric keypad north).static final int
Key code for Vstatic final int
Key code for Wstatic final int
Key code for IME.static final int
Key code for left windows key.static final int
Key code for Windows key on Firefox Linuxstatic final int
Key code for left windows key or meta.static final int
Key code for right windows key.static final int
Key code for Xstatic final int
Key code for Ystatic final int
Key code for Zstatic final int
Key code number 0 -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
isArrowKey
(int code) Determines if a key code is an arrow key.static int
maybeSwapArrowKeysForRtl
(int code, boolean isRtl) Update arrow keys for left and right based on current locale.
-
Field Details
-
KEY_A
public static final int KEY_AKey code for A- See Also:
-
KEY_B
public static final int KEY_BKey code for B- See Also:
-
KEY_C
public static final int KEY_CKey code for C- See Also:
-
KEY_D
public static final int KEY_DKey code for D- See Also:
-
KEY_E
public static final int KEY_EKey code for E- See Also:
-
KEY_F
public static final int KEY_FKey code for F- See Also:
-
KEY_G
public static final int KEY_GKey code for G- See Also:
-
KEY_H
public static final int KEY_HKey code for H- See Also:
-
KEY_I
public static final int KEY_IKey code for I- See Also:
-
KEY_J
public static final int KEY_JKey code for J- See Also:
-
KEY_K
public static final int KEY_KKey code for K- See Also:
-
KEY_L
public static final int KEY_LKey code for L- See Also:
-
KEY_M
public static final int KEY_MKey code for M- See Also:
-
KEY_N
public static final int KEY_NKey code for N- See Also:
-
KEY_O
public static final int KEY_OKey code for O- See Also:
-
KEY_P
public static final int KEY_PKey code for P- See Also:
-
KEY_Q
public static final int KEY_QKey code for Q- See Also:
-
KEY_R
public static final int KEY_RKey code for R- See Also:
-
KEY_S
public static final int KEY_SKey code for S- See Also:
-
KEY_T
public static final int KEY_TKey code for T- See Also:
-
KEY_U
public static final int KEY_UKey code for U- See Also:
-
KEY_V
public static final int KEY_VKey code for V- See Also:
-
KEY_W
public static final int KEY_WKey code for W- See Also:
-
KEY_X
public static final int KEY_XKey code for X- See Also:
-
KEY_Y
public static final int KEY_YKey code for Y- See Also:
-
KEY_Z
public static final int KEY_ZKey code for Z- See Also:
-
KEY_ZERO
public static final int KEY_ZEROKey code number 0- See Also:
-
KEY_ONE
public static final int KEY_ONEKey code number 1- See Also:
-
KEY_TWO
public static final int KEY_TWOKey code number 2- See Also:
-
KEY_THREE
public static final int KEY_THREEKey code number 3- See Also:
-
KEY_FOUR
public static final int KEY_FOURKey code number 4- See Also:
-
KEY_FIVE
public static final int KEY_FIVEKey code number 5- See Also:
-
KEY_SIX
public static final int KEY_SIXKey code number 6- See Also:
-
KEY_SEVEN
public static final int KEY_SEVENKey code number 7- See Also:
-
KEY_EIGHT
public static final int KEY_EIGHTKey code number 8- See Also:
-
KEY_NINE
public static final int KEY_NINEKey code number 9- See Also:
-
KEY_NUM_ZERO
public static final int KEY_NUM_ZEROKey code for number 0 on numeric keyboard- See Also:
-
KEY_NUM_ONE
public static final int KEY_NUM_ONEKey code for number 1 on numeric keyboard- See Also:
-
KEY_NUM_TWO
public static final int KEY_NUM_TWOKey code for number 2 on numeric keyboard- See Also:
-
KEY_NUM_THREE
public static final int KEY_NUM_THREEKey code for number 3 on numeric keyboard- See Also:
-
KEY_NUM_FOUR
public static final int KEY_NUM_FOURKey code for number 4 on numeric keyboard- See Also:
-
KEY_NUM_FIVE
public static final int KEY_NUM_FIVEKey code for number 5 on numeric keyboard- See Also:
-
KEY_NUM_SIX
public static final int KEY_NUM_SIXKey code for number 6 on numeric keyboard- See Also:
-
KEY_NUM_SEVEN
public static final int KEY_NUM_SEVENKey code for number 7 on numeric keyboard- See Also:
-
KEY_NUM_EIGHT
public static final int KEY_NUM_EIGHTKey code for number 8 on numeric keyboard- See Also:
-
KEY_NUM_NINE
public static final int KEY_NUM_NINEKey code for number 9 on numeric keyboard- See Also:
-
KEY_NUM_MULTIPLY
public static final int KEY_NUM_MULTIPLYKey code for multiply on numeric keyboard- See Also:
-
KEY_NUM_PLUS
public static final int KEY_NUM_PLUSKey code for plus on numeric keyboard- See Also:
-
KEY_NUM_MINUS
public static final int KEY_NUM_MINUSKey code for minus on numeric keyboard- See Also:
-
KEY_NUM_PERIOD
public static final int KEY_NUM_PERIODKey code for period on numeric keyboard- See Also:
-
KEY_NUM_DIVISION
public static final int KEY_NUM_DIVISIONKey code for division on numeric keyboard- See Also:
-
KEY_ALT
public static final int KEY_ALTAlt key code.- See Also:
-
KEY_BACKSPACE
public static final int KEY_BACKSPACEBackspace key code.- See Also:
-
KEY_CTRL
public static final int KEY_CTRLControl key code.- See Also:
-
KEY_DELETE
public static final int KEY_DELETEDelete key code (also numeric keypad delete).- See Also:
-
KEY_DOWN
public static final int KEY_DOWNDown arrow code (Also numeric keypad down).- See Also:
-
KEY_END
public static final int KEY_ENDEnd key code (Also numeric keypad south west).- See Also:
-
KEY_ENTER
public static final int KEY_ENTEREnter key code.- See Also:
-
KEY_ESCAPE
public static final int KEY_ESCAPEEscape key code.- See Also:
-
KEY_HOME
public static final int KEY_HOMEHome key code (Also numeric keypad north west).- See Also:
-
KEY_LEFT
public static final int KEY_LEFTLeft key code (Also numeric keypad west).- See Also:
-
KEY_PAGEDOWN
public static final int KEY_PAGEDOWNPage down key code (Also numeric keypad south east).- See Also:
-
KEY_PAGEUP
public static final int KEY_PAGEUPPage up key code (Also numeric keypad north east).- See Also:
-
KEY_RIGHT
public static final int KEY_RIGHTRight arrow key code (Also numeric keypad east).- See Also:
-
KEY_SHIFT
public static final int KEY_SHIFTShift key code.- See Also:
-
KEY_TAB
public static final int KEY_TABTab key code.- See Also:
-
KEY_UP
public static final int KEY_UPUp Arrow key code (Also numeric keypad north).- See Also:
-
KEY_F1
public static final int KEY_F1Key code for F1- See Also:
-
KEY_F2
public static final int KEY_F2Key code for F2- See Also:
-
KEY_F3
public static final int KEY_F3Key code for F3- See Also:
-
KEY_F4
public static final int KEY_F4Key code for F4- See Also:
-
KEY_F5
public static final int KEY_F5Key code for F5- See Also:
-
KEY_F6
public static final int KEY_F6Key code for F6- See Also:
-
KEY_F7
public static final int KEY_F7Key code for F7- See Also:
-
KEY_F8
public static final int KEY_F8Key code for F8- See Also:
-
KEY_F9
public static final int KEY_F9Key code for F9- See Also:
-
KEY_F10
public static final int KEY_F10Key code for F10- See Also:
-
KEY_F11
public static final int KEY_F11Key code for F11- See Also:
-
KEY_F12
public static final int KEY_F12Key code for F12- See Also:
-
KEY_WIN_KEY_FF_LINUX
public static final int KEY_WIN_KEY_FF_LINUXKey code for Windows key on Firefox Linux- See Also:
-
KEY_MAC_ENTER
public static final int KEY_MAC_ENTERKey code for Mac enter key- See Also:
-
KEY_PAUSE
public static final int KEY_PAUSEKey code for pause key- See Also:
-
KEY_CAPS_LOCK
public static final int KEY_CAPS_LOCKKey code for caps lock key- See Also:
-
KEY_SPACE
public static final int KEY_SPACEKey code for space- See Also:
-
KEY_PRINT_SCREEN
public static final int KEY_PRINT_SCREENKey code for print key- See Also:
-
KEY_INSERT
public static final int KEY_INSERTKey code for insert key (Also numeric keyboard insert).- See Also:
-
KEY_NUM_CENTER
public static final int KEY_NUM_CENTERKey code for insert key (Also num lock on FF,Safari Mac).- See Also:
-
KEY_WIN_KEY
public static final int KEY_WIN_KEYKey code for left windows key.- See Also:
-
KEY_WIN_KEY_LEFT_META
public static final int KEY_WIN_KEY_LEFT_METAKey code for left windows key or meta.- See Also:
-
KEY_WIN_KEY_RIGHT
public static final int KEY_WIN_KEY_RIGHTKey code for right windows key.- See Also:
-
KEY_CONTEXT_MENU
public static final int KEY_CONTEXT_MENUKey code for context menu key.- See Also:
-
KEY_MAC_FF_META
public static final int KEY_MAC_FF_METAKey code forKEY_WIN_KEY_LEFT_META
that Firefox fires for the meta key.- See Also:
-
KEY_NUMLOCK
public static final int KEY_NUMLOCKKey code for num lock.- See Also:
-
KEY_SCROLL_LOCK
public static final int KEY_SCROLL_LOCKKey code for scroll lock.- See Also:
-
KEY_FIRST_MEDIA_KEY
public static final int KEY_FIRST_MEDIA_KEYKey code for first OS specific media key (like volume).- See Also:
-
KEY_LAST_MEDIA_KEY
public static final int KEY_LAST_MEDIA_KEYKey code for last OS specific media key (like volume).- See Also:
-
KEY_WIN_IME
public static final int KEY_WIN_IMEKey code for IME.- See Also:
-
KEY_OPEN_BRACKET
public static final int KEY_OPEN_BRACKETKey code for open square bracket, [.- See Also:
-
KEY_CLOSE_BRACKET
public static final int KEY_CLOSE_BRACKETKey code for close square bracket, ].- See Also:
-
-
Method Details
-
isArrowKey
public static boolean isArrowKey(int code) Determines if a key code is an arrow key. -
maybeSwapArrowKeysForRtl
public static int maybeSwapArrowKeysForRtl(int code, boolean isRtl) Update arrow keys for left and right based on current locale.Note: this method is used internally by built-in GWT widgets but could be renamed/refactored without notice.
This method simplifies RTL handling in your code:
int keyCode = KeyCodes.maybeSwapArrowKeysForRtl(event.getKeyCode(), LocaleInfo.getCurrentLocale().isRTL()); switch (keyCode) { case KeyCodes.KEY_LEFT: ... // start of the line, no special RTL handling break; case KeyCodes.KEY_RIGHT: ... // end of the line, no special RTL handling break; ... }
-