Class KeyCodes

java.lang.Object
com.google.gwt.event.dom.client.KeyCodes

public class KeyCodes extends Object
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

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Key code for A
    static final int
    Alt key code.
    static final int
    Key code for B
    static final int
    Backspace key code.
    static final int
    Key code for C
    static final int
    Key code for caps lock key
    static 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 D
    static 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 E
    static final int
    Key code number 8
    static 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 F
    static final int
    Key code for F1
    static final int
    Key code for F10
    static final int
    Key code for F11
    static final int
    Key code for F12
    static final int
    Key code for F2
    static final int
    Key code for F3
    static final int
    Key code for F4
    static final int
    Key code for F5
    static final int
    Key code for F6
    static final int
    Key code for F7
    static final int
    Key code for F8
    static final int
    Key code for F9
    static final int
    Key code for first OS specific media key (like volume).
    static final int
    Key code number 5
    static final int
    Key code number 4
    static final int
    Key code for G
    static final int
    Key code for H
    static final int
    Home key code (Also numeric keypad north west).
    static final int
    Key code for I
    static final int
    Key code for insert key (Also numeric keyboard insert).
    static final int
    Key code for J
    static final int
    Key code for K
    static final int
    Key code for L
    static 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 M
    static final int
    Key code for Mac enter key
    static final int
    Key code for KEY_WIN_KEY_LEFT_META that Firefox fires for the meta key.
    static final int
    Key code for N
    static final int
    Key code number 9
    static final int
    Key code for insert key (Also num lock on FF,Safari Mac).
    static final int
    Key code for division on numeric keyboard
    static final int
    Key code for number 8 on numeric keyboard
    static final int
    Key code for number 5 on numeric keyboard
    static final int
    Key code for number 4 on numeric keyboard
    static final int
    Key code for minus on numeric keyboard
    static final int
    Key code for multiply on numeric keyboard
    static final int
    Key code for number 9 on numeric keyboard
    static final int
    Key code for number 1 on numeric keyboard
    static final int
    Key code for period on numeric keyboard
    static final int
    Key code for plus on numeric keyboard
    static final int
    Key code for number 7 on numeric keyboard
    static final int
    Key code for number 6 on numeric keyboard
    static final int
    Key code for number 3 on numeric keyboard
    static final int
    Key code for number 2 on numeric keyboard
    static final int
    Key code for number 0 on numeric keyboard
    static final int
    Key code for num lock.
    static final int
    Key code for O
    static final int
    Key code number 1
    static final int
    Key code for open square bracket, [.
    static final int
    Key code for P
    static 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 key
    static final int
    Key code for print key
    static final int
    Key code for Q
    static final int
    Key code for R
    static final int
    Right arrow key code (Also numeric keypad east).
    static final int
    Key code for S
    static final int
    Key code for scroll lock.
    static final int
    Key code number 7
    static final int
    Shift key code.
    static final int
    Key code number 6
    static final int
    Key code for space
    static final int
    Key code for T
    static final int
    Tab key code.
    static final int
    Key code number 3
    static final int
    Key code number 2
    static final int
    Key code for U
    static final int
    Up Arrow key code (Also numeric keypad north).
    static final int
    Key code for V
    static final int
    Key code for W
    static 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 Linux
    static 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 X
    static final int
    Key code for Y
    static final int
    Key code for Z
    static final int
    Key code number 0
  • Method Summary

    Modifier and Type
    Method
    Description
    static 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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • 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;
         ...
         }