Package com.google.gwt.event.dom.client
Class KeyCodes
- java.lang.Object
-
- com.google.gwt.event.dom.client.KeyCodes
-
public class KeyCodes extends java.lang.ObjectContains the native key codes previously defined inKeyboardListener. 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 inKeyboardListener.
-
-
Field Summary
Fields Modifier and Type Field Description static intKEY_AKey code for Astatic intKEY_ALTAlt key code.static intKEY_BKey code for Bstatic intKEY_BACKSPACEBackspace key code.static intKEY_CKey code for Cstatic intKEY_CAPS_LOCKKey code for caps lock keystatic intKEY_CLOSE_BRACKETKey code for close square bracket, ].static intKEY_CONTEXT_MENUKey code for context menu key.static intKEY_CTRLControl key code.static intKEY_DKey code for Dstatic intKEY_DELETEDelete key code (also numeric keypad delete).static intKEY_DOWNDown arrow code (Also numeric keypad down).static intKEY_EKey code for Estatic intKEY_EIGHTKey code number 8static intKEY_ENDEnd key code (Also numeric keypad south west).static intKEY_ENTEREnter key code.static intKEY_ESCAPEEscape key code.static intKEY_FKey code for Fstatic intKEY_F1Key code for F1static intKEY_F10Key code for F10static intKEY_F11Key code for F11static intKEY_F12Key code for F12static intKEY_F2Key code for F2static intKEY_F3Key code for F3static intKEY_F4Key code for F4static intKEY_F5Key code for F5static intKEY_F6Key code for F6static intKEY_F7Key code for F7static intKEY_F8Key code for F8static intKEY_F9Key code for F9static intKEY_FIRST_MEDIA_KEYKey code for first OS specific media key (like volume).static intKEY_FIVEKey code number 5static intKEY_FOURKey code number 4static intKEY_GKey code for Gstatic intKEY_HKey code for Hstatic intKEY_HOMEHome key code (Also numeric keypad north west).static intKEY_IKey code for Istatic intKEY_INSERTKey code for insert key (Also numeric keyboard insert).static intKEY_JKey code for Jstatic intKEY_KKey code for Kstatic intKEY_LKey code for Lstatic intKEY_LAST_MEDIA_KEYKey code for last OS specific media key (like volume).static intKEY_LEFTLeft key code (Also numeric keypad west).static intKEY_MKey code for Mstatic intKEY_MAC_ENTERKey code for Mac enter keystatic intKEY_MAC_FF_METAKey code forKEY_WIN_KEY_LEFT_METAthat Firefox fires for the meta key.static intKEY_NKey code for Nstatic intKEY_NINEKey code number 9static intKEY_NUM_CENTERKey code for insert key (Also num lock on FF,Safari Mac).static intKEY_NUM_DIVISIONKey code for division on numeric keyboardstatic intKEY_NUM_EIGHTKey code for number 8 on numeric keyboardstatic intKEY_NUM_FIVEKey code for number 5 on numeric keyboardstatic intKEY_NUM_FOURKey code for number 4 on numeric keyboardstatic intKEY_NUM_MINUSKey code for minus on numeric keyboardstatic intKEY_NUM_MULTIPLYKey code for multiply on numeric keyboardstatic intKEY_NUM_NINEKey code for number 9 on numeric keyboardstatic intKEY_NUM_ONEKey code for number 1 on numeric keyboardstatic intKEY_NUM_PERIODKey code for period on numeric keyboardstatic intKEY_NUM_PLUSKey code for plus on numeric keyboardstatic intKEY_NUM_SEVENKey code for number 7 on numeric keyboardstatic intKEY_NUM_SIXKey code for number 6 on numeric keyboardstatic intKEY_NUM_THREEKey code for number 3 on numeric keyboardstatic intKEY_NUM_TWOKey code for number 2 on numeric keyboardstatic intKEY_NUM_ZEROKey code for number 0 on numeric keyboardstatic intKEY_NUMLOCKKey code for num lock.static intKEY_OKey code for Ostatic intKEY_ONEKey code number 1static intKEY_OPEN_BRACKETKey code for open square bracket, [.static intKEY_PKey code for Pstatic intKEY_PAGEDOWNPage down key code (Also numeric keypad south east).static intKEY_PAGEUPPage up key code (Also numeric keypad north east).static intKEY_PAUSEKey code for pause keystatic intKEY_PRINT_SCREENKey code for print keystatic intKEY_QKey code for Qstatic intKEY_RKey code for Rstatic intKEY_RIGHTRight arrow key code (Also numeric keypad east).static intKEY_SKey code for Sstatic intKEY_SCROLL_LOCKKey code for scroll lock.static intKEY_SEVENKey code number 7static intKEY_SHIFTShift key code.static intKEY_SIXKey code number 6static intKEY_SPACEKey code for spacestatic intKEY_TKey code for Tstatic intKEY_TABTab key code.static intKEY_THREEKey code number 3static intKEY_TWOKey code number 2static intKEY_UKey code for Ustatic intKEY_UPUp Arrow key code (Also numeric keypad north).static intKEY_VKey code for Vstatic intKEY_WKey code for Wstatic intKEY_WIN_IMEKey code for IME.static intKEY_WIN_KEYKey code for left windows key.static intKEY_WIN_KEY_FF_LINUXKey code for Windows key on Firefox Linuxstatic intKEY_WIN_KEY_LEFT_METAKey code for left windows key or meta.static intKEY_WIN_KEY_RIGHTKey code for right windows key.static intKEY_XKey code for Xstatic intKEY_YKey code for Ystatic intKEY_ZKey code for Zstatic intKEY_ZEROKey code number 0
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanisArrowKey(int code)Determines if a key code is an arrow key.static intmaybeSwapArrowKeysForRtl(int code, boolean isRtl)Update arrow keys for left and right based on current locale.
-
-
-
Field Detail
-
KEY_A
public static final int KEY_A
Key code for A- See Also:
- Constant Field Values
-
KEY_B
public static final int KEY_B
Key code for B- See Also:
- Constant Field Values
-
KEY_C
public static final int KEY_C
Key code for C- See Also:
- Constant Field Values
-
KEY_D
public static final int KEY_D
Key code for D- See Also:
- Constant Field Values
-
KEY_E
public static final int KEY_E
Key code for E- See Also:
- Constant Field Values
-
KEY_F
public static final int KEY_F
Key code for F- See Also:
- Constant Field Values
-
KEY_G
public static final int KEY_G
Key code for G- See Also:
- Constant Field Values
-
KEY_H
public static final int KEY_H
Key code for H- See Also:
- Constant Field Values
-
KEY_I
public static final int KEY_I
Key code for I- See Also:
- Constant Field Values
-
KEY_J
public static final int KEY_J
Key code for J- See Also:
- Constant Field Values
-
KEY_K
public static final int KEY_K
Key code for K- See Also:
- Constant Field Values
-
KEY_L
public static final int KEY_L
Key code for L- See Also:
- Constant Field Values
-
KEY_M
public static final int KEY_M
Key code for M- See Also:
- Constant Field Values
-
KEY_N
public static final int KEY_N
Key code for N- See Also:
- Constant Field Values
-
KEY_O
public static final int KEY_O
Key code for O- See Also:
- Constant Field Values
-
KEY_P
public static final int KEY_P
Key code for P- See Also:
- Constant Field Values
-
KEY_Q
public static final int KEY_Q
Key code for Q- See Also:
- Constant Field Values
-
KEY_R
public static final int KEY_R
Key code for R- See Also:
- Constant Field Values
-
KEY_S
public static final int KEY_S
Key code for S- See Also:
- Constant Field Values
-
KEY_T
public static final int KEY_T
Key code for T- See Also:
- Constant Field Values
-
KEY_U
public static final int KEY_U
Key code for U- See Also:
- Constant Field Values
-
KEY_V
public static final int KEY_V
Key code for V- See Also:
- Constant Field Values
-
KEY_W
public static final int KEY_W
Key code for W- See Also:
- Constant Field Values
-
KEY_X
public static final int KEY_X
Key code for X- See Also:
- Constant Field Values
-
KEY_Y
public static final int KEY_Y
Key code for Y- See Also:
- Constant Field Values
-
KEY_Z
public static final int KEY_Z
Key code for Z- See Also:
- Constant Field Values
-
KEY_ZERO
public static final int KEY_ZERO
Key code number 0- See Also:
- Constant Field Values
-
KEY_ONE
public static final int KEY_ONE
Key code number 1- See Also:
- Constant Field Values
-
KEY_TWO
public static final int KEY_TWO
Key code number 2- See Also:
- Constant Field Values
-
KEY_THREE
public static final int KEY_THREE
Key code number 3- See Also:
- Constant Field Values
-
KEY_FOUR
public static final int KEY_FOUR
Key code number 4- See Also:
- Constant Field Values
-
KEY_FIVE
public static final int KEY_FIVE
Key code number 5- See Also:
- Constant Field Values
-
KEY_SIX
public static final int KEY_SIX
Key code number 6- See Also:
- Constant Field Values
-
KEY_SEVEN
public static final int KEY_SEVEN
Key code number 7- See Also:
- Constant Field Values
-
KEY_EIGHT
public static final int KEY_EIGHT
Key code number 8- See Also:
- Constant Field Values
-
KEY_NINE
public static final int KEY_NINE
Key code number 9- See Also:
- Constant Field Values
-
KEY_NUM_ZERO
public static final int KEY_NUM_ZERO
Key code for number 0 on numeric keyboard- See Also:
- Constant Field Values
-
KEY_NUM_ONE
public static final int KEY_NUM_ONE
Key code for number 1 on numeric keyboard- See Also:
- Constant Field Values
-
KEY_NUM_TWO
public static final int KEY_NUM_TWO
Key code for number 2 on numeric keyboard- See Also:
- Constant Field Values
-
KEY_NUM_THREE
public static final int KEY_NUM_THREE
Key code for number 3 on numeric keyboard- See Also:
- Constant Field Values
-
KEY_NUM_FOUR
public static final int KEY_NUM_FOUR
Key code for number 4 on numeric keyboard- See Also:
- Constant Field Values
-
KEY_NUM_FIVE
public static final int KEY_NUM_FIVE
Key code for number 5 on numeric keyboard- See Also:
- Constant Field Values
-
KEY_NUM_SIX
public static final int KEY_NUM_SIX
Key code for number 6 on numeric keyboard- See Also:
- Constant Field Values
-
KEY_NUM_SEVEN
public static final int KEY_NUM_SEVEN
Key code for number 7 on numeric keyboard- See Also:
- Constant Field Values
-
KEY_NUM_EIGHT
public static final int KEY_NUM_EIGHT
Key code for number 8 on numeric keyboard- See Also:
- Constant Field Values
-
KEY_NUM_NINE
public static final int KEY_NUM_NINE
Key code for number 9 on numeric keyboard- See Also:
- Constant Field Values
-
KEY_NUM_MULTIPLY
public static final int KEY_NUM_MULTIPLY
Key code for multiply on numeric keyboard- See Also:
- Constant Field Values
-
KEY_NUM_PLUS
public static final int KEY_NUM_PLUS
Key code for plus on numeric keyboard- See Also:
- Constant Field Values
-
KEY_NUM_MINUS
public static final int KEY_NUM_MINUS
Key code for minus on numeric keyboard- See Also:
- Constant Field Values
-
KEY_NUM_PERIOD
public static final int KEY_NUM_PERIOD
Key code for period on numeric keyboard- See Also:
- Constant Field Values
-
KEY_NUM_DIVISION
public static final int KEY_NUM_DIVISION
Key code for division on numeric keyboard- See Also:
- Constant Field Values
-
KEY_ALT
public static final int KEY_ALT
Alt key code.- See Also:
- Constant Field Values
-
KEY_BACKSPACE
public static final int KEY_BACKSPACE
Backspace key code.- See Also:
- Constant Field Values
-
KEY_CTRL
public static final int KEY_CTRL
Control key code.- See Also:
- Constant Field Values
-
KEY_DELETE
public static final int KEY_DELETE
Delete key code (also numeric keypad delete).- See Also:
- Constant Field Values
-
KEY_DOWN
public static final int KEY_DOWN
Down arrow code (Also numeric keypad down).- See Also:
- Constant Field Values
-
KEY_END
public static final int KEY_END
End key code (Also numeric keypad south west).- See Also:
- Constant Field Values
-
KEY_ENTER
public static final int KEY_ENTER
Enter key code.- See Also:
- Constant Field Values
-
KEY_ESCAPE
public static final int KEY_ESCAPE
Escape key code.- See Also:
- Constant Field Values
-
KEY_HOME
public static final int KEY_HOME
Home key code (Also numeric keypad north west).- See Also:
- Constant Field Values
-
KEY_LEFT
public static final int KEY_LEFT
Left key code (Also numeric keypad west).- See Also:
- Constant Field Values
-
KEY_PAGEDOWN
public static final int KEY_PAGEDOWN
Page down key code (Also numeric keypad south east).- See Also:
- Constant Field Values
-
KEY_PAGEUP
public static final int KEY_PAGEUP
Page up key code (Also numeric keypad north east).- See Also:
- Constant Field Values
-
KEY_RIGHT
public static final int KEY_RIGHT
Right arrow key code (Also numeric keypad east).- See Also:
- Constant Field Values
-
KEY_SHIFT
public static final int KEY_SHIFT
Shift key code.- See Also:
- Constant Field Values
-
KEY_TAB
public static final int KEY_TAB
Tab key code.- See Also:
- Constant Field Values
-
KEY_UP
public static final int KEY_UP
Up Arrow key code (Also numeric keypad north).- See Also:
- Constant Field Values
-
KEY_F1
public static final int KEY_F1
Key code for F1- See Also:
- Constant Field Values
-
KEY_F2
public static final int KEY_F2
Key code for F2- See Also:
- Constant Field Values
-
KEY_F3
public static final int KEY_F3
Key code for F3- See Also:
- Constant Field Values
-
KEY_F4
public static final int KEY_F4
Key code for F4- See Also:
- Constant Field Values
-
KEY_F5
public static final int KEY_F5
Key code for F5- See Also:
- Constant Field Values
-
KEY_F6
public static final int KEY_F6
Key code for F6- See Also:
- Constant Field Values
-
KEY_F7
public static final int KEY_F7
Key code for F7- See Also:
- Constant Field Values
-
KEY_F8
public static final int KEY_F8
Key code for F8- See Also:
- Constant Field Values
-
KEY_F9
public static final int KEY_F9
Key code for F9- See Also:
- Constant Field Values
-
KEY_F10
public static final int KEY_F10
Key code for F10- See Also:
- Constant Field Values
-
KEY_F11
public static final int KEY_F11
Key code for F11- See Also:
- Constant Field Values
-
KEY_F12
public static final int KEY_F12
Key code for F12- See Also:
- Constant Field Values
-
KEY_WIN_KEY_FF_LINUX
public static final int KEY_WIN_KEY_FF_LINUX
Key code for Windows key on Firefox Linux- See Also:
- Constant Field Values
-
KEY_MAC_ENTER
public static final int KEY_MAC_ENTER
Key code for Mac enter key- See Also:
- Constant Field Values
-
KEY_PAUSE
public static final int KEY_PAUSE
Key code for pause key- See Also:
- Constant Field Values
-
KEY_CAPS_LOCK
public static final int KEY_CAPS_LOCK
Key code for caps lock key- See Also:
- Constant Field Values
-
KEY_SPACE
public static final int KEY_SPACE
Key code for space- See Also:
- Constant Field Values
-
KEY_PRINT_SCREEN
public static final int KEY_PRINT_SCREEN
Key code for print key- See Also:
- Constant Field Values
-
KEY_INSERT
public static final int KEY_INSERT
Key code for insert key (Also numeric keyboard insert).- See Also:
- Constant Field Values
-
KEY_NUM_CENTER
public static final int KEY_NUM_CENTER
Key code for insert key (Also num lock on FF,Safari Mac).- See Also:
- Constant Field Values
-
KEY_WIN_KEY
public static final int KEY_WIN_KEY
Key code for left windows key.- See Also:
- Constant Field Values
-
KEY_WIN_KEY_LEFT_META
public static final int KEY_WIN_KEY_LEFT_META
Key code for left windows key or meta.- See Also:
- Constant Field Values
-
KEY_WIN_KEY_RIGHT
public static final int KEY_WIN_KEY_RIGHT
Key code for right windows key.- See Also:
- Constant Field Values
-
KEY_CONTEXT_MENU
public static final int KEY_CONTEXT_MENU
Key code for context menu key.- See Also:
- Constant Field Values
-
KEY_MAC_FF_META
public static final int KEY_MAC_FF_META
Key code forKEY_WIN_KEY_LEFT_METAthat Firefox fires for the meta key.- See Also:
- Constant Field Values
-
KEY_NUMLOCK
public static final int KEY_NUMLOCK
Key code for num lock.- See Also:
- Constant Field Values
-
KEY_SCROLL_LOCK
public static final int KEY_SCROLL_LOCK
Key code for scroll lock.- See Also:
- Constant Field Values
-
KEY_FIRST_MEDIA_KEY
public static final int KEY_FIRST_MEDIA_KEY
Key code for first OS specific media key (like volume).- See Also:
- Constant Field Values
-
KEY_LAST_MEDIA_KEY
public static final int KEY_LAST_MEDIA_KEY
Key code for last OS specific media key (like volume).- See Also:
- Constant Field Values
-
KEY_WIN_IME
public static final int KEY_WIN_IME
Key code for IME.- See Also:
- Constant Field Values
-
KEY_OPEN_BRACKET
public static final int KEY_OPEN_BRACKET
Key code for open square bracket, [.- See Also:
- Constant Field Values
-
KEY_CLOSE_BRACKET
public static final int KEY_CLOSE_BRACKET
Key code for close square bracket, ].- See Also:
- Constant Field Values
-
-
Method Detail
-
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; ... }
-
-