diff options
Diffstat (limited to 'src/newt/classes/com/jogamp')
-rw-r--r-- | src/newt/classes/com/jogamp/newt/event/KeyEvent.java | 1062 | ||||
-rw-r--r-- | src/newt/classes/com/jogamp/newt/event/UTFKeyUtil.java | 82 |
2 files changed, 564 insertions, 580 deletions
diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java index bda60004e..45bccf964 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java @@ -34,7 +34,11 @@ package com.jogamp.newt.event; +import com.jogamp.common.util.IntBitfield; + /** + * <a name="eventDelivery"><h5>KeyEvent Delivery</h5></a> + * * Key events are delivered in the following order: * <p> * <table border="0"> @@ -77,32 +81,84 @@ package com.jogamp.newt.event; * and {@link #EVENT_KEY_RELEASED released} events excluding {@link #isAutoRepeat() auto-repeat}. * They will also influence subsequent event's {@link #getModifiers() modifier} bits while pressed. * </p> + * + * <a name="unicodeMapping"><h5>Unicode Mapping</h5></a> + * <p> + * {@link #getKeyChar() Key-chars}, as well as + * {@link #isPrintableKey() printable} {@link #getKeyCode() key-codes} and {@link #getKeySymbol() key-symbols} + * use the UTF-16 unicode space w/o collision. + * + * </p> + * <p> + * Non-{@link #isPrintableKey() printable} {@link #getKeyCode() key-codes} and {@link #getKeySymbol() key-symbols}, + * i.e. {@link #isModifierKey() modifier-} and {@link #isActionKey() action-}keys, + * are mapped to unicode's control and private range and do not collide w/ {@link #isPrintableKey() printable} unicode values + * with the following exception. + * </p> + * + * <a name="unicodeCollision"><h5>Unicode Collision</h5></a> + * <p> + * The following {@link #getKeyCode() Key-code}s and {@link #getKeySymbol() key-symbol}s collide w/ unicode space:<br/> + * <table border="1"> + * <tr><th>unicode range</th> <th>virtual key code</th> <th>unicode character</th></tr> + * <tr><td>[0x61 .. 0x78]</td> <td>[{@link #VK_F1}..{@link #VK_F24}]</td> <td>['a'..'x']</td></tr> + * </table> + * </p> + * <p> + * Collision was chosen for {@link #getKeyCode() Key-code} and {@link #getKeySymbol() key-symbol} mapping + * to allow a minimal code range, i.e. <code>[0..255]</code>. + * The reduced code range in turn allows the implementation to utilize fast and small lookup tables, + * e.g. to implement a key-press state tracker. + * </p> + * <pre> + * http://www.utf8-chartable.de/unicode-utf8-table.pl + * http://www.unicode.org/Public/5.1.0/ucd/PropList.txt + * https://en.wikipedia.org/wiki/Mapping_of_Unicode_characters + * https://en.wikipedia.org/wiki/Unicode_control_characters + * https://en.wikipedia.org/wiki/Private_Use_%28Unicode%29#Private_Use_Areas + * </pre> + * </p> */ @SuppressWarnings("serial") public class KeyEvent extends InputEvent { - public KeyEvent(short eventType, Object source, long when, int modifiers, short keyCode, short keySym, char keyChar) { - super(eventType, source, when, modifiers); + private KeyEvent(short eventType, Object source, long when, int modifiers, short keyCode, short keySym, int keySymModMask, char keyChar) { + super(eventType, source, when, modifiers | keySymModMask); this.keyCode=keyCode; this.keySym=keySym; this.keyChar=keyChar; { // cache modifier and action flags byte _flags = 0; - if( isModifierKey(keySym) ) { - _flags |= F_MODIFIER_MASK; - } - if( isActionKey(keySym) ) { - _flags |= F_ACTION_MASK; - } - if( 0 == _flags && VK_UNDEFINED != keySym && NULL_CHAR != keyChar ) { + if( isPrintableKey(keySym, false) && isPrintableKey((short)keyChar, true) ) { _flags |= F_PRINTABLE_MASK; + } else { + if( 0 != keySymModMask ) { + _flags |= F_MODIFIER_MASK; + } else { + // A = U - ( P + M ) + _flags |= F_ACTION_MASK; + } } flags = _flags; + + // + // Validate flags + // + final int pma_bits = flags & ( F_PRINTABLE_MASK | F_MODIFIER_MASK | F_ACTION_MASK ) ; + final int pma_count = IntBitfield.getBitCount(pma_bits); + if ( 1 != pma_count ) { + throw new InternalError("Key must be either of type printable, modifier or action - but it is of "+pma_count+" types: "+this); + } } } + + public static KeyEvent create(short eventType, Object source, long when, int modifiers, short keyCode, short keySym, char keyChar) { + return new KeyEvent(eventType, source, when, modifiers, keyCode, keySym, getModifierMask(keySym), keyChar); + } /** - * Returns the <i>UTF-16</i> character reflecting the {@link #getKeySymbol() key symbol}. + * Returns the <i>UTF-16</i> character reflecting the {@link #getKeySymbol() key symbol} + * incl. active {@link #isModifierKey() modifiers}. * @see #getKeySymbol() * @see #getKeyCode() */ @@ -113,8 +169,9 @@ public class KeyEvent extends InputEvent /** * Returns the virtual <i>key symbol</i> reflecting the current <i>keyboard layout</i>. * <p> - * For {@link #isPrintableKey() printable keys}, the <i>key symbol</i> is the unshifted - * representation of the {@link #getKeyChar() UTF-16 key char}. + * For {@link #isPrintableKey() printable keys}, the <i>key symbol</i> is the {@link #isModifierKey() unmodified} + * representation of the UTF-16 {@link #getKeyChar() key char}.<br/> + * E.g. symbol [{@link #VK_A}, 'A'] for char 'a'. * </p> * @see #isPrintableKey() * @see #getKeyChar() @@ -136,10 +193,6 @@ public class KeyEvent extends InputEvent * <code>QWERTZ</code> is active. The {@link #getKeySymbol() key symbol} of the former is * {@link #VK_Y}, where the latter produces {@link #VK_Y}. * </p> - * <p> - * <b>Disclaimer</b>: In case <i>key code</i> is not implemented on your platform (OSX, ..) - * the {@link #getKeySymbol() key symbol} is returned. - * </p> * @see #getKeyChar() * @see #getKeySymbol() */ @@ -169,6 +222,18 @@ public class KeyEvent extends InputEvent } } + /** + * @param keyChar UTF16 value to map. It is expected that the incoming keyChar value is unshifted and unmodified, + * however, lower case a-z is mapped to {@link KeyEvent#VK_A} - {@link KeyEvent#VK_Z}. + * @return {@link KeyEvent} virtual key (VK) value. + */ + public static short utf16ToVKey(char keyChar) { + if( 'a' <= keyChar && keyChar <= 'z' ) { + return (short) ( ( keyChar - 'a' ) + KeyEvent.VK_A ); + } + return (short) keyChar; + } + /** * Returns <code>true</code> if the given <code>virtualKey</code> represents a modifier key, otherwise <code>false</code>. * <p> @@ -188,6 +253,25 @@ public class KeyEvent extends InputEvent } } + /** + * If <code>vKey</code> is a {@link #isModifierKey() modifier key}, method returns the corresponding modifier mask, + * otherwise 0. + */ + public static int getModifierMask(short vKey) { + switch (vKey) { + case VK_SHIFT: + return InputEvent.SHIFT_MASK; + case VK_CONTROL: + return InputEvent.CTRL_MASK; + case VK_ALT: + case VK_ALT_GRAPH: + return InputEvent.ALT_MASK; + case VK_META: + return InputEvent.META_MASK; + } + return 0; + } + /** * Returns <code>true</code> if {@link #getKeySymbol() key symbol} represents a modifier key, * otherwise <code>false</code>. @@ -201,106 +285,67 @@ public class KeyEvent extends InputEvent public final boolean isModifierKey() { return 0 != ( F_MODIFIER_MASK & flags ) ; } - - /** - * Returns <code>true</code> if the given <code>virtualKey</code> represents a non-printable and - * non-{@link #isModifierKey(short) modifier} action key, otherwise <code>false</code>. - * <p> - * An action key is one of {@link #VK_HOME}, {@link #VK_END}, {@link #VK_PAGE_UP}, {@link #VK_PAGE_DOWN}, {@link #VK_UP}, {@link #VK_PAGE_DOWN}, - * {@link #VK_LEFT}, {@link #VK_RIGHT}, {@link #VK_F1}-{@link #VK_F24}, {@link #VK_PRINTSCREEN}, {@link #VK_CAPS_LOCK}, {@link #VK_PAUSE}, - * {@link #VK_INSERT}, {@link #VK_HELP}, {@link #VK_WINDOWS}, etc ... - * </p> - */ - public static boolean isActionKey(short vKey) { - if( ( VK_F1 <= vKey && vKey <= VK_F24 ) || - ( VK_ALL_CANDIDATES <= vKey && vKey <= VK_INPUT_METHOD_ON_OFF ) || - ( VK_CUT <= vKey && vKey <= VK_STOP ) ) { - return true; - } - - switch (vKey) { - case VK_CANCEL: - case VK_CLEAR: - case VK_PAUSE: - case VK_CAPS_LOCK: - case VK_ESCAPE: - case VK_PAGE_UP: - case VK_PAGE_DOWN: - case VK_END: - case VK_HOME: - case VK_LEFT: - case VK_UP: - case VK_RIGHT: - case VK_DOWN: - case VK_DELETE: - case VK_NUM_LOCK: - case VK_SCROLL_LOCK: - - case VK_PRINTSCREEN: - case VK_INSERT: - case VK_HELP: - case VK_META: - case VK_KP_UP: - case VK_KP_DOWN: - case VK_KP_LEFT: - case VK_KP_RIGHT: - - case VK_DEAD_VOICED_SOUND: - case VK_DEAD_SEMIVOICED_SOUND: - - case VK_WINDOWS: - case VK_CONTEXT_MENU: - case VK_FINAL: - - case VK_CONVERT: - case VK_NONCONVERT: - case VK_ACCEPT: - case VK_MODECHANGE: - - case VK_KANA: - case VK_KANJI: - - case VK_ALPHANUMERIC: - case VK_KATAKANA: - case VK_HIRAGANA: - case VK_FULL_WIDTH: - case VK_HALF_WIDTH: - case VK_ROMAN_CHARACTERS: - - case VK_COMPOSE: - case VK_BEGIN: - case VK_KEYBOARD_INVISIBLE: - return true; - } - return false; - } /** - * Returns <code>true</code> if {@link #getKeySymbol() key symbol} represents a non-printable and - * non-{@link #isModifierKey(short) modifier} action key, otherwise <code>false</code>. + * Returns <code>true</code> if {@link #getKeySymbol() key symbol} represents a non-printable and + * non-{@link #isModifierKey(short) modifier} action key, otherwise <code>false</code>. * <p> - * See {@link #isActionKey(short)} for details. + * Hence it is the set A of all keys U w/o printable P and w/o modifiers M: + * <code> A = U - ( P + M ) </code> * </p> + * @see #isPrintableKey() + * @see #isModifierKey() */ public final boolean isActionKey() { return 0 != ( F_ACTION_MASK & flags ) ; } - /** - * Returns <code>true</code> if given <code>virtualKey</code> represents a printable character, - * i.e. a value other than {@link #VK_UNDEFINED} and neither a {@link #isModifierKey(short) modifier key} - * nor an {@link #isActionKey(short) action key}. + /** + * Returns <code>true</code> if given <code>uniChar</code> represents a printable character, + * i.e. a value other than {@link #VK_UNDEFINED} and not a control or non-printable private code. + * <p> + * A printable character is neither a {@link #isModifierKey(short) modifier key}, nor an {@link #isActionKey(short) action key}. + * </p> + * <p> * Otherwise returns <code>false</code>. + * </p> + * <p> + * Distinction of key character and virtual key code is made due to <a href="#unicodeCollision">unicode collision</a>. + * </p> + * + * @param uniChar the UTF-16 unicode value, which maybe a virtual key code or key character. + * @param isKeyChar true if <code>uniChar</code> is a key character, otherwise a virtual key code */ - public static boolean isPrintableKey(short vKey) { - return VK_UNDEFINED != vKey && !isModifierKey(vKey) && !isActionKey(vKey); + public static boolean isPrintableKey(final short uniChar, final boolean isKeyChar) { + if( VK_UNDEFINED == uniChar ) { + return false; + } + if( !isKeyChar ) { + if( ( nonPrintableKeys[0].min <= uniChar && uniChar <= nonPrintableKeys[0].max ) || + ( nonPrintableKeys[1].min <= uniChar && uniChar <= nonPrintableKeys[1].max ) || + ( nonPrintableKeys[2].min <= uniChar && uniChar <= nonPrintableKeys[2].max ) || + ( nonPrintableKeys[3].min <= uniChar && uniChar <= nonPrintableKeys[3].max ) ) { + return false; + } + + } else { + if( ( nonPrintableKeys[0].inclKeyChar && nonPrintableKeys[0].min <= uniChar && uniChar <= nonPrintableKeys[0].max ) || + ( nonPrintableKeys[1].inclKeyChar && nonPrintableKeys[1].min <= uniChar && uniChar <= nonPrintableKeys[1].max ) || + ( nonPrintableKeys[2].inclKeyChar && nonPrintableKeys[2].min <= uniChar && uniChar <= nonPrintableKeys[2].max ) || + ( nonPrintableKeys[3].inclKeyChar && nonPrintableKeys[3].min <= uniChar && uniChar <= nonPrintableKeys[3].max ) ) { + return false; + } + } + return true; } /** - * Returns <code>true</code> if {@link #getKeySymbol() key symbol} represents a printable character, - * i.e. a value other than {@link #VK_UNDEFINED} and neither a {@link #isModifierKey(short) modifier key} - * nor an {@link #isActionKey(short) action key}. The {@link #getKeyChar() key char} value must also be - * different than {@link #NULL_CHAR}. + * Returns <code>true</code> if {@link #getKeySymbol() key symbol} and {@link #getKeyChar() key char} + * represents a printable character, i.e. a value other than {@link #VK_UNDEFINED} + * and not a control or non-printable private code. + * <p> + * A printable character is neither a {@link #isModifierKey(short) modifier key}, nor an {@link #isActionKey(short) action key}. + * </p> * <p> * Otherwise returns <code>false</code>. * </p> @@ -327,578 +372,599 @@ public class KeyEvent extends InputEvent */ public static final short EVENT_KEY_TYPED = 302; + /** + * This value, {@code '\0'}, is used to indicate that the keyChar is unknown or not printable. + */ + public static final char NULL_CHAR = '\0'; + /* Virtual key codes. */ - public static final short VK_CANCEL = (short) 0x03; - public static final short VK_BACK_SPACE = (short) 0x08; // '\b' - public static final short VK_TAB = (short) 0x09; // '\t' - public static final short VK_ENTER = (short) 0x0A; // '\n' - public static final short VK_CLEAR = (short) 0x0C; - public static final short VK_SHIFT = (short) 0x10; - public static final short VK_CONTROL = (short) 0x11; + public static class NonPrintableRange { + /** min. unicode value, inclusive */ + public short min; + /** max. unicode value, inclusive */ + public short max; + /** true if valid for keyChar values as well, otherwise only valid for keyCode and keySym due to collision. */ + public final boolean inclKeyChar; + private NonPrintableRange(short min, short max, boolean inclKeyChar) { + this.min = min; + this.max = max; + this.inclKeyChar = inclKeyChar; + } + }; + /** Non printable key ranges, currently fixed to an aray of size 4. */ + public final static NonPrintableRange[] nonPrintableKeys = { new NonPrintableRange( (short)0x0000, (short)0x001F, true ), + new NonPrintableRange( (short)0x0061, (short)0x0078, false), + new NonPrintableRange( (short)0x007F, (short)0x009F, true ), + new NonPrintableRange( (short)0xE000, (short)0xF8FF, true ) }; + + // + // Unicode: Non printable controls: [0x00 - 0x1F] + // + /** - * Constant for the ALT function key, i.e. left ALT key. + * This value, {@value}, is used to indicate that the keyCode is unknown. */ + public static final short VK_UNDEFINED = (short) 0x0; + + static final short VK_FREE01 = (short) 0x01; + + /** Constant for the HOME function key. ASCII: Start Of Text. */ + public static final short VK_HOME = (short) 0x02; + + /** Constant for the END function key. ASCII: End Of Text. */ + public static final short VK_END = (short) 0x03; + + /** Constant for the END function key. ASCII: End Of Transmission. */ + public static final short VK_FINAL = (short) 0x04; + + /** Constant for the PRINT function key. ASCII: Enquiry. */ + public static final short VK_PRINTSCREEN = (short) 0x05; + + static final short VK_FREE06 = (short) 0x06; + static final short VK_FREE07 = (short) 0x07; + + /** Constant for the BACK SPACE key "\b", matching ASCII. */ + public static final short VK_BACK_SPACE = (short) 0x08; + + /** Constant for the HORIZ TAB key "\t", matching ASCII. */ + public static final short VK_TAB = (short) 0x09; + + /** Constant for the ENTER key, i.e. LINE FEED "\n", matching ASCII. */ + public static final short VK_ENTER = (short) 0x0A; + + /** Constant for the PAGE DOWN function key. ASCII: Vertical Tabulation. */ + public static final short VK_PAGE_DOWN = (short) 0x0B; + + /** Constant for the CLEAR key, i.e. FORM FEED, matching ASCII. */ + public static final short VK_CLEAR = (short) 0x0C; + + static final short VK_FREE0D = (short) 0x0D; + static final short VK_FREE0E = (short) 0x0E; + + /** Constant for the CTRL function key. ASCII: shift-in. */ + public static final short VK_SHIFT = (short) 0x0F; + + /** Constant for the PAGE UP function key. ASCII: Data Link Escape. */ + public static final short VK_PAGE_UP = (short) 0x10; + + /** Constant for the CTRL function key. ASCII: device-ctrl-one. */ + public static final short VK_CONTROL = (short) 0x11; + + /** Constant for the left ALT function key. ASCII: device-ctrl-two. */ public static final short VK_ALT = (short) 0x12; - public static final short VK_PAUSE = (short) 0x13; + + /** Constant for the ALT_GRAPH function key, i.e. right ALT key. ASCII: device-ctrl-three. */ + public static final short VK_ALT_GRAPH = (short) 0x13; + + /** Constant for the CAPS LOCK function key. ASCII: device-ctrl-four. */ public static final short VK_CAPS_LOCK = (short) 0x14; + + static final short VK_FREE15 = (short) 0x15; + + /** Constant for the PAUSE function key. ASCII: sync-idle. */ + public static final short VK_PAUSE = (short) 0x16; + + /** <b>scroll lock</b> key. ASCII: End Of Transmission Block. */ + public static final short VK_SCROLL_LOCK = (short) 0x17; + + /** Constant for the CANCEL function key. ASCII: Cancel. */ + public static final short VK_CANCEL = (short) 0x18; + + static final short VK_FREE19 = (short) 0x19; + + /** Constant for the INSERT function key. ASCII: Substitute. */ + public static final short VK_INSERT = (short) 0x1A; + + /** Constant for the ESCAPE function key. ASCII: Escape. */ public static final short VK_ESCAPE = (short) 0x1B; - public static final short VK_SPACE = (short) 0x20; - public static final short VK_PAGE_UP = (short) 0x21; - public static final short VK_PAGE_DOWN = (short) 0x22; - public static final short VK_END = (short) 0x23; - public static final short VK_HOME = (short) 0x24; + + /** Constant for the Convert function key, Japanese "henkan". ASCII: File Separator. */ + public static final short VK_CONVERT = (short) 0x1C; - /** - * Constant for the non-numpad <b>left</b> arrow key. - * @see #VK_KP_LEFT - */ - public static final short VK_LEFT = (short) 0x25; + /** Constant for the Don't Convert function key, Japanese "muhenkan". ASCII: Group Separator.*/ + public static final short VK_NONCONVERT = (short) 0x1D; - /** - * Constant for the non-numpad <b>up</b> arrow key. - * @see #VK_KP_UP - */ - public static final short VK_UP = (short) 0x26; + /** Constant for the Accept or Commit function key, Japanese "kakutei". ASCII: Record Separator.*/ + public static final short VK_ACCEPT = (short) 0x1E; - /** - * Constant for the non-numpad <b>right</b> arrow key. - * @see #VK_KP_RIGHT - */ - public static final short VK_RIGHT = (short) 0x27; + /** Constant for the Mode Change (?). ASCII: Unit Separator.*/ + public static final short VK_MODECHANGE = (short) 0x1F; - /** - * Constant for the non-numpad <b>down</b> arrow key. - * @see #VK_KP_DOWN - */ - public static final short VK_DOWN = (short) 0x28; + // + // Unicode: Printable [0x20 - 0x7E] + // NOTE: Collision of 'a' - 'x' [0x61 .. 0x78], used for keyCode/keySym Fn function keys + // + + /** Constant for the SPACE function key. ASCII: SPACE. */ + public static final short VK_SPACE = (short) 0x20; + + /** Constant for the "!" key. */ + public static final short VK_EXCLAMATION_MARK = (short) 0x21; - /** - * Constant for the comma key, "," - */ - public static final short VK_COMMA = (short) 0x2C; + /** Constant for the """ key. */ + public static final short VK_QUOTEDBL = (short) 0x22; + + /** Constant for the "#" key. */ + public static final short VK_NUMBER_SIGN = (short) 0x23; - /** - * Constant for the minus key, "-" - * @since 1.2 - */ + /** Constant for the "$" key. */ + public static final short VK_DOLLAR = (short) 0x24; + + /** Constant for the "%" key. */ + public static final short VK_PERCENT = (short) 0x25; + + /** Constant for the "&" key. */ + public static final short VK_AMPERSAND = (short) 0x26; + + /** Constant for the "'" key. */ + public static final short VK_QUOTE = (short) 0x27; + + /** Constant for the "(" key. */ + public static final short VK_LEFT_PARENTHESIS = (short) 0x28; + + /** Constant for the ")" key. */ + public static final short VK_RIGHT_PARENTHESIS = (short) 0x29; + + /** Constant for the "*" key */ + public static final short VK_ASTERISK = (short) 0x2A; + + /** Constant for the "+" key. */ + public static final short VK_PLUS = (short) 0x2B; + + /** Constant for the comma key, "," */ + public static final short VK_COMMA = (short) 0x2C; + + /** Constant for the minus key, "-" */ public static final short VK_MINUS = (short) 0x2D; - /** - * Constant for the period key, "." - */ + /** Constant for the period key, "." */ public static final short VK_PERIOD = (short) 0x2E; - /** - * Constant for the forward slash key, "/" - */ + /** Constant for the forward slash key, "/" */ public static final short VK_SLASH = (short) 0x2F; - /** VK_0 thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39) */ + /** VK_0 thru VK_9 are the same as UTF16/ASCII '0' thru '9' [0x30 - 0x39] */ public static final short VK_0 = (short) 0x30; + /** See {@link #VK_0}. */ public static final short VK_1 = (short) 0x31; + /** See {@link #VK_0}. */ public static final short VK_2 = (short) 0x32; + /** See {@link #VK_0}. */ public static final short VK_3 = (short) 0x33; + /** See {@link #VK_0}. */ public static final short VK_4 = (short) 0x34; + /** See {@link #VK_0}. */ public static final short VK_5 = (short) 0x35; + /** See {@link #VK_0}. */ public static final short VK_6 = (short) 0x36; + /** See {@link #VK_0}. */ public static final short VK_7 = (short) 0x37; + /** See {@link #VK_0}. */ public static final short VK_8 = (short) 0x38; + /** See {@link #VK_0}. */ public static final short VK_9 = (short) 0x39; - /** - * Constant for the semicolon key, ";" - */ + /** Constant for the ":" key. */ + public static final short VK_COLON = (short) 0x3A; + + /** Constant for the semicolon key, ";" */ public static final short VK_SEMICOLON = (short) 0x3B; - /** - * Constant for the equals key, "=" - */ + /** Constant for the equals key, "<" */ + public static final short VK_LESS = (short) 0x3C; + + /** Constant for the equals key, "=" */ public static final short VK_EQUALS = (short) 0x3D; - /** VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A) */ + /** Constant for the equals key, ">" */ + public static final short VK_GREATER = (short) 0x3E; + + /** Constant for the equals key, "?" */ + public static final short VK_QUESTIONMARK = (short) 0x3F; + + /** Constant for the equals key, "@" */ + public static final short VK_AT = (short) 0x40; + + /** VK_A thru VK_Z are the same as Capital UTF16/ASCII 'A' thru 'Z' (0x41 - 0x5A) */ public static final short VK_A = (short) 0x41; + /** See {@link #VK_A}. */ public static final short VK_B = (short) 0x42; + /** See {@link #VK_A}. */ public static final short VK_C = (short) 0x43; + /** See {@link #VK_A}. */ public static final short VK_D = (short) 0x44; + /** See {@link #VK_A}. */ public static final short VK_E = (short) 0x45; + /** See {@link #VK_A}. */ public static final short VK_F = (short) 0x46; + /** See {@link #VK_A}. */ public static final short VK_G = (short) 0x47; + /** See {@link #VK_A}. */ public static final short VK_H = (short) 0x48; + /** See {@link #VK_A}. */ public static final short VK_I = (short) 0x49; + /** See {@link #VK_A}. */ public static final short VK_J = (short) 0x4A; + /** See {@link #VK_A}. */ public static final short VK_K = (short) 0x4B; + /** See {@link #VK_A}. */ public static final short VK_L = (short) 0x4C; + /** See {@link #VK_A}. */ public static final short VK_M = (short) 0x4D; + /** See {@link #VK_A}. */ public static final short VK_N = (short) 0x4E; + /** See {@link #VK_A}. */ public static final short VK_O = (short) 0x4F; + /** See {@link #VK_A}. */ public static final short VK_P = (short) 0x50; + /** See {@link #VK_A}. */ public static final short VK_Q = (short) 0x51; + /** See {@link #VK_A}. */ public static final short VK_R = (short) 0x52; + /** See {@link #VK_A}. */ public static final short VK_S = (short) 0x53; + /** See {@link #VK_A}. */ public static final short VK_T = (short) 0x54; + /** See {@link #VK_A}. */ public static final short VK_U = (short) 0x55; + /** See {@link #VK_A}. */ public static final short VK_V = (short) 0x56; + /** See {@link #VK_A}. */ public static final short VK_W = (short) 0x57; + /** See {@link #VK_A}. */ public static final short VK_X = (short) 0x58; + /** See {@link #VK_A}. */ public static final short VK_Y = (short) 0x59; + /** See {@link #VK_A}. */ public static final short VK_Z = (short) 0x5A; - /** - * Constant for the open bracket key, "[" - */ + /** Constant for the open bracket key, "[" */ public static final short VK_OPEN_BRACKET = (short) 0x5B; - /** - * Constant for the back slash key, "\" - */ + /**Constant for the back slash key, "\" */ public static final short VK_BACK_SLASH = (short) 0x5C; - /** - * Constant for the close bracket key, "]" - */ + /** Constant for the close bracket key, "]" */ public static final short VK_CLOSE_BRACKET = (short) 0x5D; - public static final short VK_NUMPAD0 = (short) 0x60; - public static final short VK_NUMPAD1 = (short) 0x61; - public static final short VK_NUMPAD2 = (short) 0x62; - public static final short VK_NUMPAD3 = (short) 0x63; - public static final short VK_NUMPAD4 = (short) 0x64; - public static final short VK_NUMPAD5 = (short) 0x65; - public static final short VK_NUMPAD6 = (short) 0x66; - public static final short VK_NUMPAD7 = (short) 0x67; - public static final short VK_NUMPAD8 = (short) 0x68; - public static final short VK_NUMPAD9 = (short) 0x69; - public static final short VK_MULTIPLY = (short) 0x6A; - public static final short VK_ADD = (short) 0x6B; + /** Constant for the "^" key. */ + public static final short VK_CIRCUMFLEX = (short) 0x5E; + /** Constant for the "_" key */ + public static final short VK_UNDERSCORE = (short) 0x5F; + + /** Constant for the "`" key */ + public static final short VK_BACK_QUOTE = (short) 0x60; + + /** Small UTF/ASCII 'a' thru 'z' (0x61 - 0x7a) - Not used for keyCode / keySym. */ + /** - * Constant for the Numpad Separator key. + * Constant for the F<i>n</i> function keys. + * <p> + * F1..F24, i.e. F<i>n</i>, are mapped from on <code>0x60+n</code> -> <code>[0x61 .. 0x78]</code>. + * </p> + * <p> + * <b>Warning:</b> The F<i>n</i> function keys <b>do collide</b> with unicode characters small 'a' thru 'x'!<br/> + * See <a href="#unicodeCollision">Unicode Collision</a> for details. + * </p> */ - public static final short VK_SEPARATOR = (short) 0x6C; + public static final short VK_F1 = (short) ( 0x60+ 1 ); - public static final short VK_SUBTRACT = (short) 0x6D; - public static final short VK_DECIMAL = (short) 0x6E; - public static final short VK_DIVIDE = (short) 0x6F; - public static final short VK_DELETE = (short) 0x7F; /* ASCII DEL */ - public static final short VK_NUM_LOCK = (short) 0x90; - public static final short VK_SCROLL_LOCK = (short) 0x91; + /** Constant for the F2 function key. See {@link #VK_F1}. */ + public static final short VK_F2 = (short) ( 0x60+ 2 ); - /** Constant for the F1 function key. */ - public static final short VK_F1 = (short) 0x70; + /** Constant for the F3 function key. See {@link #VK_F1}. */ + public static final short VK_F3 = (short) ( 0x60+ 3 ); - /** Constant for the F2 function key. */ - public static final short VK_F2 = (short) 0x71; + /** Constant for the F4 function key. See {@link #VK_F1}. */ + public static final short VK_F4 = (short) ( 0x60+ 4 ); - /** Constant for the F3 function key. */ - public static final short VK_F3 = (short) 0x72; + /** Constant for the F5 function key. See {@link #VK_F1}. */ + public static final short VK_F5 = (short) ( 0x60+ 5 ); - /** Constant for the F4 function key. */ - public static final short VK_F4 = (short) 0x73; + /** Constant for the F6 function key. See {@link #VK_F1}. */ + public static final short VK_F6 = (short) ( 0x60+ 6 ); - /** Constant for the F5 function key. */ - public static final short VK_F5 = (short) 0x74; + /** Constant for the F7 function key. See {@link #VK_F1}. */ + public static final short VK_F7 = (short) ( 0x60+ 7 ); - /** Constant for the F6 function key. */ - public static final short VK_F6 = (short) 0x75; + /** Constant for the F8 function key. See {@link #VK_F1}. */ + public static final short VK_F8 = (short) ( 0x60+ 8 ); - /** Constant for the F7 function key. */ - public static final short VK_F7 = (short) 0x76; + /** Constant for the F9 function key. See {@link #VK_F1}. */ + public static final short VK_F9 = (short) ( 0x60+ 9 ); - /** Constant for the F8 function key. */ - public static final short VK_F8 = (short) 0x77; + /** Constant for the F11 function key. See {@link #VK_F1}. */ + public static final short VK_F10 = (short) ( 0x60+10 ); - /** Constant for the F9 function key. */ - public static final short VK_F9 = (short) 0x78; + /** Constant for the F11 function key. See {@link #VK_F1}. */ + public static final short VK_F11 = (short) ( 0x60+11 ); - /** Constant for the F10 function key. */ - public static final short VK_F10 = (short) 0x79; + /** Constant for the F12 function key. See {@link #VK_F1}.*/ + public static final short VK_F12 = (short) ( 0x60+12 ); - /** Constant for the F11 function key. */ - public static final short VK_F11 = (short) 0x7A; + /** Constant for the F13 function key. See {@link #VK_F1}. */ + public static final short VK_F13 = (short) ( 0x60+13 ); - /** Constant for the F12 function key. */ - public static final short VK_F12 = (short) 0x7B; + /** Constant for the F14 function key. See {@link #VK_F1}. */ + public static final short VK_F14 = (short) ( 0x60+14 ); - /** - * Constant for the F13 function key. - * <p>F13 - F24 are used on IBM 3270 keyboard; use random range for constants.</p> - */ - public static final short VK_F13 = (short) 0xF000; + /** Constant for the F15 function key. See {@link #VK_F1}. */ + public static final short VK_F15 = (short) ( 0x60+15 ); - /** - * Constant for the F14 function key. - * <p>F13 - F24 are used on IBM 3270 keyboard; use random range for constants.</p> - */ - public static final short VK_F14 = (short) 0xF001; - - /** - * Constant for the F15 function key. - * <p>F13 - F24 are used on IBM 3270 keyboard; use random range for constants.</p> - */ - public static final short VK_F15 = (short) 0xF002; - - /** - * Constant for the F16 function key. - * <p>F13 - F24 are used on IBM 3270 keyboard; use random range for constants.</p> - */ - public static final short VK_F16 = (short) 0xF003; - - /** - * Constant for the F17 function key. - * <p>F13 - F24 are used on IBM 3270 keyboard; use random range for constants.</p> - */ - public static final short VK_F17 = (short) 0xF004; + /** Constant for the F16 function key. See {@link #VK_F1}. */ + public static final short VK_F16 = (short) ( 0x60+16 ); - /** - * Constant for the F18 function key. - * <p>F13 - F24 are used on IBM 3270 keyboard; use random range for constants.</p> - */ - public static final short VK_F18 = (short) 0xF005; + /** Constant for the F17 function key. See {@link #VK_F1}. */ + public static final short VK_F17 = (short) ( 0x60+17 ); - /** - * Constant for the F19 function key. - * <p>F13 - F24 are used on IBM 3270 keyboard; use random range for constants.</p> - */ - public static final short VK_F19 = (short) 0xF006; + /** Constant for the F18 function key. See {@link #VK_F1}. */ + public static final short VK_F18 = (short) ( 0x60+18 ); - /** - * Constant for the F20 function key. - * <p>F13 - F24 are used on IBM 3270 keyboard; use random range for constants.</p> - */ - public static final short VK_F20 = (short) 0xF007; + /** Constant for the F19 function key. See {@link #VK_F1}. */ + public static final short VK_F19 = (short) ( 0x60+19 ); - /** - * Constant for the F21 function key. - * <p>F13 - F24 are used on IBM 3270 keyboard; use random range for constants.</p> - */ - public static final short VK_F21 = (short) 0xF008; + /** Constant for the F20 function key. See {@link #VK_F1}. */ + public static final short VK_F20 = (short) ( 0x60+20 ); - /** - * Constant for the F22 function key. - * <p>F13 - F24 are used on IBM 3270 keyboard; use random range for constants.</p> - */ - public static final short VK_F22 = (short) 0xF009; + /** Constant for the F21 function key. See {@link #VK_F1}. */ + public static final short VK_F21 = (short) ( 0x60+21 ); - /** - * Constant for the F23 function key. - * <p>F13 - F24 are used on IBM 3270 keyboard; use random range for constants.</p> - */ - public static final short VK_F23 = (short) 0xF00A; + /** Constant for the F22 function key. See {@link #VK_F1}. */ + public static final short VK_F22 = (short) ( 0x60+22 ); - /** - * Constant for the F24 function key. - * <p>F13 - F24 are used on IBM 3270 keyboard; use random range for constants.</p> - */ - public static final short VK_F24 = (short) 0xF00B; + /** Constant for the F23 function key. See {@link #VK_F1}. */ + public static final short VK_F23 = (short) ( 0x60+23 ); - public static final short VK_PRINTSCREEN = (short) 0x9A; - public static final short VK_INSERT = (short) 0x9B; - public static final short VK_HELP = (short) 0x9C; - public static final short VK_META = (short) 0x9D; + /** Constant for the F24 function key. See {@link #VK_F1}. */ + public static final short VK_F24 = (short) ( 0x60+24 ); - public static final short VK_BACK_QUOTE = (short) 0xC0; - public static final short VK_QUOTE = (short) 0xDE; + + /** Constant for the "{" key */ + public static final short VK_LEFT_BRACE = (short) 0x7B; + /** Constant for the "|" key */ + public static final short VK_PIPE = (short) 0x7C; + /** Constant for the "}" key */ + public static final short VK_RIGHT_BRACE = (short) 0x7D; + + /** Constant for the "~" key, matching ASCII */ + public static final short VK_TILDE = (short) 0x7E; + + // + // Unicode: Non printable controls: [0x7F - 0x9F] + // + + /** Constant for the DEL key, matching ASCII. Non printable UTF control. */ + public static final short VK_DELETE = (short) 0x7F; + + /** Numeric keypad VK_NUMPAD0 thru VK_NUMPAD9 are mapped to UTF control (0x80 - 0x89). Non printable UTF control. */ + public static final short VK_NUMPAD0 = (short) 0x80; + /** See {@link #VK_NUMPAD0}. */ + public static final short VK_NUMPAD1 = (short) 0x81; + /** See {@link #VK_NUMPAD0}. */ + public static final short VK_NUMPAD2 = (short) 0x82; + /** See {@link #VK_NUMPAD0}. */ + public static final short VK_NUMPAD3 = (short) 0x83; + /** See {@link #VK_NUMPAD0}. */ + public static final short VK_NUMPAD4 = (short) 0x84; + /** See {@link #VK_NUMPAD0}. */ + public static final short VK_NUMPAD5 = (short) 0x85; + /** See {@link #VK_NUMPAD0}. */ + public static final short VK_NUMPAD6 = (short) 0x86; + /** See {@link #VK_NUMPAD0}. */ + public static final short VK_NUMPAD7 = (short) 0x87; + /** See {@link #VK_NUMPAD0}. */ + public static final short VK_NUMPAD8 = (short) 0x88; + /** See {@link #VK_NUMPAD0}. */ + public static final short VK_NUMPAD9 = (short) 0x89; + + /** Numeric keypad <b>decimal separator</b> key. Non printable UTF control. */ + public static final short VK_DECIMAL = (short) 0x8A; + + /** Numeric keypad <b>decimal separator</b> key. Non printable UTF control. */ + public static final short VK_SEPARATOR = (short) 0x8B; + + /** Numeric keypad <b>add</b> key. Non printable UTF control. */ + public static final short VK_ADD = (short) 0x8C; - /** - * Constant for the numeric keypad <b>up</b> arrow key. - * @see #VK_UP - */ - public static final short VK_KP_UP = (short) 0xE0; + /** Numeric keypad <b>subtract</b> key. Non printable UTF control. */ + public static final short VK_SUBTRACT = (short) 0x8D; + + /** Numeric keypad <b>multiply</b> key. Non printable UTF control. */ + public static final short VK_MULTIPLY = (short) 0x8E; + + /** Numeric keypad <b>divide</b> key. Non printable UTF control. */ + public static final short VK_DIVIDE = (short) 0x8F; + + /** Numeric keypad <b>num lock</b> key. Non printable UTF control. */ + public static final short VK_NUM_LOCK = (short) 0x90; + + /** Numeric keypad <b>left</b> arrow key, for cursor pad see {@link #VK_LEFT}. Non printable UTF control. */ + public static final short VK_KP_LEFT = (short) 0x91; - /** - * Constant for the numeric keypad <b>down</b> arrow key. - * @see #VK_DOWN - */ - public static final short VK_KP_DOWN = (short) 0xE1; + /** Numeric keypad <b>up</b> arrow key, for cursor pad see {@link #VK_UP}. Non printable UTF control. */ + public static final short VK_KP_UP = (short) 0x92; - /** - * Constant for the numeric keypad <b>left</b> arrow key. - * @see #VK_LEFT - */ - public static final short VK_KP_LEFT = (short) 0xE2; + /** Constant for the numeric keypad <b>right</b> arrow key, for cursor pad see {@link #VK_RIGHT}. Non printable UTF control. */ + public static final short VK_KP_RIGHT = (short) 0x93; + + /** Numeric keypad <b>down</b> arrow key, for cursor pad see {@link #VK_DOWN}. Non printable UTF control. */ + public static final short VK_KP_DOWN = (short) 0x94; - /** - * Constant for the numeric keypad <b>right</b> arrow key. - * @see #VK_RIGHT - */ - public static final short VK_KP_RIGHT = (short) 0xE3; - - /** For European keyboards */ - public static final short VK_DEAD_GRAVE = (short) 0x80; - /** For European keyboards */ - public static final short VK_DEAD_ACUTE = (short) 0x81; - /** For European keyboards */ - public static final short VK_DEAD_CIRCUMFLEX = (short) 0x82; - /** For European keyboards */ - public static final short VK_DEAD_TILDE = (short) 0x83; - /** For European keyboards */ - public static final short VK_DEAD_MACRON = (short) 0x84; - /** For European keyboards */ - public static final short VK_DEAD_BREVE = (short) 0x85; - /** For European keyboards */ - public static final short VK_DEAD_ABOVEDOT = (short) 0x86; - /** For European keyboards */ - public static final short VK_DEAD_DIAERESIS = (short) 0x87; - /** For European keyboards */ - public static final short VK_DEAD_ABOVERING = (short) 0x88; - /** For European keyboards */ - public static final short VK_DEAD_DOUBLEACUTE = (short) 0x89; - /** For European keyboards */ - public static final short VK_DEAD_CARON = (short) 0x8a; - /** For European keyboards */ - public static final short VK_DEAD_CEDILLA = (short) 0x8b; - /** For European keyboards */ - public static final short VK_DEAD_OGONEK = (short) 0x8c; - /** For European keyboards */ - public static final short VK_DEAD_IOTA = (short) 0x8d; - /** For European keyboards */ - public static final short VK_DEAD_VOICED_SOUND = (short) 0x8e; - /** For European keyboards */ - public static final short VK_DEAD_SEMIVOICED_SOUND = (short) 0x8f; - - /** For European keyboards */ - public static final short VK_AMPERSAND = (short) 0x96; - /** For European keyboards */ - public static final short VK_ASTERISK = (short) 0x97; - /** For European keyboards */ - public static final short VK_QUOTEDBL = (short) 0x98; - /** For European keyboards */ - public static final short VK_LESS = (short) 0x99; - - /** For European keyboards */ - public static final short VK_GREATER = (short) 0xa0; - /** For European keyboards */ - public static final short VK_BRACELEFT = (short) 0xa1; - /** For European keyboards */ - public static final short VK_BRACERIGHT = (short) 0xa2; + /** Constant for the cursor-pad <b>left</b> arrow key, for numerical pad see {@link #VK_KP_LEFT}*/ + public static final short VK_LEFT = (short) 0x95; - /** - * Constant for the "@" key. - */ - public static final short VK_AT = (short) 0x0200; + /** Constant for the cursor-pad <b>left</b> arrow key, for numerical pad see {@link #VK_KP_UP}.*/ + public static final short VK_UP = (short) 0x96; - /** - * Constant for the ":" key. - */ - public static final short VK_COLON = (short) 0x0201; + /** Constant for the cursor-pad <b>left</b> arrow key, for numerical pad see {@link #VK_KP_RIGHT}.*/ + public static final short VK_RIGHT = (short) 0x97; - /** - * Constant for the "^" key. - */ - public static final short VK_CIRCUMFLEX = (short) 0x0202; + /** Constant for the cursor-pad <b>left</b> arrow key, for numerical pad see {@link #VK_KP_DOWN}.*/ + public static final short VK_DOWN = (short) 0x98; + + /** Constant for the Context Menu key. */ + public static final short VK_CONTEXT_MENU = (short) 0x99; /** - * Constant for the "$" key. + * Constant for the MS "Windows" function key. + * It is used for both the left and right version of the key. */ - public static final short VK_DOLLAR = (short) 0x0203; + public static final short VK_WINDOWS = (short) 0x9A; - /** - * Constant for the Euro currency sign key. - */ - public static final short VK_EURO_SIGN = (short) 0x0204; + /** Constant for the Meta function key. */ + public static final short VK_META = (short) 0x9B; + + /** Constant for the Help function key. */ + public static final short VK_HELP = (short) 0x9C; + + /** Constant for the Compose function key. */ + public static final short VK_COMPOSE = (short) 0x9D; - /** - * Constant for the "!" key. - */ - public static final short VK_EXCLAMATION_MARK = (short) 0x0205; + /** Constant for the Begin function key. */ + public static final short VK_BEGIN = (short) 0x9E; - /** - * Constant for the inverted exclamation mark key. - */ - public static final short VK_INVERTED_EXCLAMATION_MARK = (short) 0x0206; + /** Constant for the Stop function key. */ + public static final short VK_STOP = (short) 0x9F; + + // + // Unicode: Printable [0x00A0 - 0xDFFF] + // + + /** Constant for the inverted exclamation mark key. */ + public static final short VK_INVERTED_EXCLAMATION_MARK = (short) 0xA1; + + /** Constant for the Euro currency sign key. */ + public static final short VK_EURO_SIGN = (short) 0x20AC; - /** - * Constant for the "(" key. - */ - public static final short VK_LEFT_PARENTHESIS = (short) 0x0207; + // + // Unicode: Private 0xE000 - 0xF8FF (Marked Non-Printable) + // + + /* for Sun keyboards */ + public static final short VK_CUT = (short) 0xF879; + public static final short VK_COPY = (short) 0xF87A; + public static final short VK_PASTE = (short) 0xF87B; + public static final short VK_UNDO = (short) 0xF87C; + public static final short VK_AGAIN = (short) 0xF87D; + public static final short VK_FIND = (short) 0xF87E; + public static final short VK_PROPS = (short) 0xF87F; - /** - * Constant for the "#" key. - */ - public static final short VK_NUMBER_SIGN = (short) 0x0208; + /* for input method support on Asian Keyboards */ /** - * Constant for the "+" key. + * Constant for the input method on/off key. */ - public static final short VK_PLUS = (short) 0x0209; - + /* Japanese PC 106 keyboard: kanji. Japanese Solaris keyboard: nihongo */ + public static final short VK_INPUT_METHOD_ON_OFF = (short) 0xF890; + /** - * Constant for the ")" key. + * Constant for the Code Input function key. */ - public static final short VK_RIGHT_PARENTHESIS = (short) 0x020A; + /* Japanese PC 106 keyboard - VK_ALPHANUMERIC + ALT: kanji bangou */ + public static final short VK_CODE_INPUT = (short) 0xF891; /** - * Constant for the "_" key. + * Constant for the Roman Characters function key. */ - public static final short VK_UNDERSCORE = (short) 0x020B; + /* Japanese PC 106 keyboard: roumaji */ + public static final short VK_ROMAN_CHARACTERS = (short) 0xF892; /** - * Constant for the Microsoft Windows "Windows" key. - * It is used for both the left and right version of the key. + * Constant for the All Candidates function key. */ - public static final short VK_WINDOWS = (short) 0x020C; + /* Japanese PC 106 keyboard - VK_CONVERT + ALT: zenkouho */ + public static final short VK_ALL_CANDIDATES = (short) 0xF893; /** - * Constant for the Microsoft Windows Context Menu key. + * Constant for the Previous Candidate function key. */ - public static final short VK_CONTEXT_MENU = (short) 0x020D; - - /* for input method support on Asian Keyboards */ - - /* not clear what this means - listed in Microsoft Windows API */ - public static final short VK_FINAL = (short) 0x0018; - - /** Constant for the Convert function key. */ - /* Japanese PC 106 keyboard, Japanese Solaris keyboard: henkan */ - public static final short VK_CONVERT = (short) 0x001C; - - /** Constant for the Don't Convert function key. */ - /* Japanese PC 106 keyboard: muhenkan */ - public static final short VK_NONCONVERT = (short) 0x001D; - - /** Constant for the Accept or Commit function key. */ - /* Japanese Solaris keyboard: kakutei */ - public static final short VK_ACCEPT = (short) 0x001E; - - /* not clear what this means - listed in Microsoft Windows API */ - public static final short VK_MODECHANGE = (short) 0x001F; - - /* replaced by VK_KANA_LOCK for Microsoft Windows and Solaris; - might still be used on other platforms */ - public static final short VK_KANA = (short) 0x0015; - - /* replaced by VK_INPUT_METHOD_ON_OFF for Microsoft Windows and Solaris; - might still be used for other platforms */ - public static final short VK_KANJI = (short) 0x0019; + /* Japanese PC 106 keyboard - VK_CONVERT + SHIFT: maekouho */ + public static final short VK_PREVIOUS_CANDIDATE = (short) 0xF894; /** * Constant for the Alphanumeric function key. */ /* Japanese PC 106 keyboard: eisuu */ - public static final short VK_ALPHANUMERIC = (short) 0x00F0; + public static final short VK_ALPHANUMERIC = (short) 0xF895; /** * Constant for the Katakana function key. */ /* Japanese PC 106 keyboard: katakana */ - public static final short VK_KATAKANA = (short) 0x00F1; + public static final short VK_KATAKANA = (short) 0xF896; /** * Constant for the Hiragana function key. */ /* Japanese PC 106 keyboard: hiragana */ - public static final short VK_HIRAGANA = (short) 0x00F2; + public static final short VK_HIRAGANA = (short) 0xF897; /** * Constant for the Full-Width Characters function key. */ /* Japanese PC 106 keyboard: zenkaku */ - public static final short VK_FULL_WIDTH = (short) 0x00F3; + public static final short VK_FULL_WIDTH = (short) 0xF898; /** * Constant for the Half-Width Characters function key. */ /* Japanese PC 106 keyboard: hankaku */ - public static final short VK_HALF_WIDTH = (short) 0x00F4; - - /** - * Constant for the Roman Characters function key. - */ - /* Japanese PC 106 keyboard: roumaji */ - public static final short VK_ROMAN_CHARACTERS = (short) 0x00F5; - - /** - * Constant for the All Candidates function key. - */ - /* Japanese PC 106 keyboard - VK_CONVERT + ALT: zenkouho */ - public static final short VK_ALL_CANDIDATES = (short) 0x0100; - - /** - * Constant for the Previous Candidate function key. - */ - /* Japanese PC 106 keyboard - VK_CONVERT + SHIFT: maekouho */ - public static final short VK_PREVIOUS_CANDIDATE = (short) 0x0101; - - /** - * Constant for the Code Input function key. - */ - /* Japanese PC 106 keyboard - VK_ALPHANUMERIC + ALT: kanji bangou */ - public static final short VK_CODE_INPUT = (short) 0x0102; + public static final short VK_HALF_WIDTH = (short) 0xF89A; /** * Constant for the Japanese-Katakana function key. * This key switches to a Japanese input method and selects its Katakana input mode. */ /* Japanese Macintosh keyboard - VK_JAPANESE_HIRAGANA + SHIFT */ - public static final short VK_JAPANESE_KATAKANA = (short) 0x0103; + public static final short VK_JAPANESE_KATAKANA = (short) 0xF89B; /** * Constant for the Japanese-Hiragana function key. * This key switches to a Japanese input method and selects its Hiragana input mode. */ /* Japanese Macintosh keyboard */ - public static final short VK_JAPANESE_HIRAGANA = (short) 0x0104; + public static final short VK_JAPANESE_HIRAGANA = (short) 0xF89C; /** * Constant for the Japanese-Roman function key. * This key switches to a Japanese input method and selects its Roman-Direct input mode. */ /* Japanese Macintosh keyboard */ - public static final short VK_JAPANESE_ROMAN = (short) 0x0105; + public static final short VK_JAPANESE_ROMAN = (short) 0xF89D; /** * Constant for the locking Kana function key. * This key locks the keyboard into a Kana layout. */ /* Japanese PC 106 keyboard with special Windows driver - eisuu + Control; Japanese Solaris keyboard: kana */ - public static final short VK_KANA_LOCK = (short) 0x0106; - - /** - * Constant for the input method on/off key. - */ - /* Japanese PC 106 keyboard: kanji. Japanese Solaris keyboard: nihongo */ - public static final short VK_INPUT_METHOD_ON_OFF = (short) 0x0107; - - /* for Sun keyboards */ - public static final short VK_CUT = (short) 0xFFD1; - public static final short VK_COPY = (short) 0xFFCD; - public static final short VK_PASTE = (short) 0xFFCF; - public static final short VK_UNDO = (short) 0xFFCB; - public static final short VK_AGAIN = (short) 0xFFC9; - public static final short VK_FIND = (short) 0xFFD0; - public static final short VK_PROPS = (short) 0xFFCA; - public static final short VK_STOP = (short) 0xFFC8; - - /** - * Constant for the Compose function key. - */ - public static final short VK_COMPOSE = (short) 0xFF20; - - /** - * Constant for the ALT_GRAPH function key, i.e. right ALT key. - */ - public static final short VK_ALT_GRAPH = (short) 0xFF7E; - - /** - * Constant for the Begin key. - */ - public static final short VK_BEGIN = (short) 0xFF58; + public static final short VK_KANA_LOCK = (short) 0xF89F; /** * Constant for Keyboard became invisible, e.g. Android's soft keyboard Back button hit while keyboard is visible. */ - public static final short VK_KEYBOARD_INVISIBLE = (short) 0xDEAD; - - /** - * This value, {@value}, is used to indicate that the keyCode is unknown. - */ - public static final short VK_UNDEFINED = (short) 0x0; - - /** - * This value, {@code '\0'}, is used to indicate that the keyChar is unknown or not printable. - */ - public static final char NULL_CHAR = '\0'; + public static final short VK_KEYBOARD_INVISIBLE = (short) 0xF8FF; } diff --git a/src/newt/classes/com/jogamp/newt/event/UTFKeyUtil.java b/src/newt/classes/com/jogamp/newt/event/UTFKeyUtil.java deleted file mode 100644 index 73afa0993..000000000 --- a/src/newt/classes/com/jogamp/newt/event/UTFKeyUtil.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Copyright 2013 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.newt.event; - -import com.jogamp.newt.event.KeyEvent; - -public class UTFKeyUtil { - - // - // UTF Key Constants - // - private static final char UTF_Equal = '='; - private static final char UTF_Minus = '-'; - private static final char UTF_RightBracket = ']'; - private static final char UTF_LeftBracket = '['; - private static final char UTF_Quote = '\''; - private static final char UTF_Semicolon = ';'; - private static final char UTF_Backslash = '\\'; - private static final char UTF_Comma = ','; - private static final char UTF_Slash = '/'; - private static final char UTF_Period = '.'; - private static final char UTF_Grave = '`'; // back quote - - /** - * @param keyChar UTF16 value to map. Note: Lower case values are preferred. - * @return {@link KeyEvent} virtual key (VK) value if possible, - * otherwise simply the UTF16 value of type short as a last resort. - */ - public static short utf16ToVKey(char keyChar) { - if( 'a' <= keyChar && keyChar <= 'z' ) { - return (short) ( ( keyChar - 'a' ) + KeyEvent.VK_A ); - } - if( '0' <= keyChar && keyChar <= '9' ) { - return (short) ( ( keyChar - '0' ) + KeyEvent.VK_0 ); - } - switch(keyChar) { - // - // KeyCodes (Layout Dependent) - // - case UTF_Equal: return KeyEvent.VK_EQUALS; - case UTF_Minus: return KeyEvent.VK_MINUS; - case UTF_RightBracket: return KeyEvent.VK_CLOSE_BRACKET; - case UTF_LeftBracket: return KeyEvent.VK_OPEN_BRACKET; - case UTF_Quote: return KeyEvent.VK_QUOTE; - case UTF_Semicolon: return KeyEvent.VK_SEMICOLON; - case UTF_Backslash: return KeyEvent.VK_BACK_SLASH; - case UTF_Comma: return KeyEvent.VK_COMMA; - case UTF_Slash: return KeyEvent.VK_SLASH; - case UTF_Period: return KeyEvent.VK_PERIOD; - case UTF_Grave: return KeyEvent.VK_BACK_QUOTE; // KeyEvent.VK_DEAD_GRAVE - } - if( 'A' <= keyChar && keyChar <= 'Z' ) { - return (short) ( ( keyChar - 'A' ) + KeyEvent.VK_A ); - } - return (short) keyChar; - } -} |