| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of html; | 5 part of html; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Defines the keycode values for keys that are returned by | 8 * Defines the keycode values for keys that are returned by |
| 9 * KeyboardEvent.keyCode. | 9 * KeyboardEvent.keyCode. |
| 10 * | 10 * |
| 11 * Important note: There is substantial divergence in how different browsers | 11 * Important note: There is substantial divergence in how different browsers |
| 12 * handle keycodes and their variants in different locales/keyboard layouts. We | 12 * handle keycodes and their variants in different locales/keyboard layouts. We |
| 13 * provide these constants to help make code processing keys more readable. | 13 * provide these constants to help make code processing keys more readable. |
| 14 */ | 14 */ |
| 15 abstract class KeyCode { | 15 abstract class KeyCode { |
| 16 // These constant names were borrowed from Closure's Keycode enumeration | 16 // These constant names were borrowed from Closure's Keycode enumeration |
| 17 // class. | 17 // class. |
| 18 // http://closure-library.googlecode.com/svn/docs/closure_goog_events_keycodes
.js.source.html | 18 // http://closure-library.googlecode.com/svn/docs/closure_goog_events_keycodes
.js.source.html |
| 19 static const int WIN_KEY_FF_LINUX = 0; | 19 static const int WIN_KEY_FF_LINUX = 0; |
| 20 static const int MAC_ENTER = 3; | 20 static const int MAC_ENTER = 3; |
| 21 static const int BACKSPACE = 8; | 21 static const int BACKSPACE = 8; |
| 22 static const int TAB = 9; | 22 static const int TAB = 9; |
| 23 /** NUM_CENTER is also NUMLOCK for FF and Safari on Mac. */ | 23 /** NUM_CENTER is also NUMLOCK for FF and Safari on Mac. */ |
| 24 static const int NUM_CENTER = 12; | 24 static const int NUM_CENTER = 12; |
| 25 static const int ENTER = 13; | 25 static const int ENTER = 13; |
| 26 static const int SHIFT = 16; | 26 static const int SHIFT = 16; |
| 27 static const int CTRL = 17; | 27 static const int CTRL = 17; |
| 28 static const int ALT = 18; | 28 static const int ALT = 18; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 * Returns true if the keyCode produces a (US keyboard) character. | 203 * Returns true if the keyCode produces a (US keyboard) character. |
| 204 * Note: This does not (yet) cover characters on non-US keyboards (Russian, | 204 * Note: This does not (yet) cover characters on non-US keyboards (Russian, |
| 205 * Hebrew, etc.). | 205 * Hebrew, etc.). |
| 206 */ | 206 */ |
| 207 static bool isCharacterKey(int keyCode) { | 207 static bool isCharacterKey(int keyCode) { |
| 208 if ((keyCode >= ZERO && keyCode <= NINE) || | 208 if ((keyCode >= ZERO && keyCode <= NINE) || |
| 209 (keyCode >= NUM_ZERO && keyCode <= NUM_MULTIPLY) || | 209 (keyCode >= NUM_ZERO && keyCode <= NUM_MULTIPLY) || |
| 210 (keyCode >= A && keyCode <= Z)) { | 210 (keyCode >= A && keyCode <= Z)) { |
| 211 return true; | 211 return true; |
| 212 } | 212 } |
| 213 | 213 |
| 214 // Safari sends zero key code for non-latin characters. | 214 // Safari sends zero key code for non-latin characters. |
| 215 if (_Device.isWebKit && keyCode == 0) { | 215 if (Device.isWebKit && keyCode == 0) { |
| 216 return true; | 216 return true; |
| 217 } | 217 } |
| 218 | 218 |
| 219 return (keyCode == SPACE || keyCode == QUESTION_MARK || keyCode == NUM_PLUS | 219 return (keyCode == SPACE || keyCode == QUESTION_MARK || keyCode == NUM_PLUS |
| 220 || keyCode == NUM_MINUS || keyCode == NUM_PERIOD || | 220 || keyCode == NUM_MINUS || keyCode == NUM_PERIOD || |
| 221 keyCode == NUM_DIVISION || keyCode == SEMICOLON || | 221 keyCode == NUM_DIVISION || keyCode == SEMICOLON || |
| 222 keyCode == FF_SEMICOLON || keyCode == DASH || keyCode == EQUALS || | 222 keyCode == FF_SEMICOLON || keyCode == DASH || keyCode == EQUALS || |
| 223 keyCode == FF_EQUALS || keyCode == COMMA || keyCode == PERIOD || | 223 keyCode == FF_EQUALS || keyCode == COMMA || keyCode == PERIOD || |
| 224 keyCode == SLASH || keyCode == APOSTROPHE || keyCode == SINGLE_QUOTE || | 224 keyCode == SLASH || keyCode == APOSTROPHE || keyCode == SINGLE_QUOTE || |
| 225 keyCode == OPEN_SQUARE_BRACKET || keyCode == BACKSLASH || | 225 keyCode == OPEN_SQUARE_BRACKET || keyCode == BACKSLASH || |
| 226 keyCode == CLOSE_SQUARE_BRACKET); | 226 keyCode == CLOSE_SQUARE_BRACKET); |
| 227 } | 227 } |
| 228 } | 228 } |
| OLD | NEW |