Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Unified Diff: sdk/lib/html/src/KeyCode.dart

Issue 11416249: Make KeyboardEvent cross-browser consistent. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: moved instance variables to constructor Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/html/scripts/htmlrenamer.py ('k') | sdk/lib/html/src/KeyboardEventController.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/html/src/KeyCode.dart
diff --git a/sdk/lib/html/src/KeyCode.dart b/sdk/lib/html/src/KeyCode.dart
index 4faa53d558733e0cdab6ccea61ba53ba8fae3409..b2c81b3d3bb162c008d7a1678763337355645fe1 100644
--- a/sdk/lib/html/src/KeyCode.dart
+++ b/sdk/lib/html/src/KeyCode.dart
@@ -195,4 +195,34 @@ abstract class KeyCode {
static const int WIN_KEY = 224;
static const int MAC_FF_META = 224;
static const int WIN_IME = 229;
+
+ /** A sentinel value if the keycode could not be determined. */
+ static const int UNKNOWN = -1;
+
+ /**
+ * Returns true if the keyCode produces a (US keyboard) character.
+ * Note: This does not (yet) cover characters on non-US keyboards (Russian,
+ * Hebrew, etc.).
+ */
+ static bool isCharacterKey(int keyCode) {
+ if ((keyCode >= ZERO && keyCode <= NINE) ||
+ (keyCode >= NUM_ZERO && keyCode <= NUM_MULTIPLY) ||
+ (keyCode >= A && keyCode <= Z)) {
+ return true;
+ }
+
+ // Safari sends zero key code for non-latin characters.
+ if (_Device.isWebKit && keyCode == 0) {
+ return true;
+ }
+
+ return (keyCode == SPACE || keyCode == QUESTION_MARK || keyCode == NUM_PLUS
+ || keyCode == NUM_MINUS || keyCode == NUM_PERIOD ||
+ keyCode == NUM_DIVISION || keyCode == SEMICOLON ||
+ keyCode == FF_SEMICOLON || keyCode == DASH || keyCode == EQUALS ||
+ keyCode == FF_EQUALS || keyCode == COMMA || keyCode == PERIOD ||
+ keyCode == SLASH || keyCode == APOSTROPHE || keyCode == SINGLE_QUOTE ||
+ keyCode == OPEN_SQUARE_BRACKET || keyCode == BACKSLASH ||
+ keyCode == CLOSE_SQUARE_BRACKET);
+ }
}
« no previous file with comments | « sdk/lib/html/scripts/htmlrenamer.py ('k') | sdk/lib/html/src/KeyboardEventController.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698