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

Side by Side Diff: tools/dom/src/KeyCode.dart

Issue 23455033: Fully polyfill KeyEvent so that you can programmatically create your own "keyboard" events. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 *
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
229 /**
230 * Experimental helper function for converting keyCodes to keyNames for the
231 * keyIdentifier attribute still used in browsers not updated with current
232 * spec. This is an imperfect conversion! It will need to be refined, but
233 * hopefully it can just completely go away once all the browsers update to
234 * follow the DOM3 spec.
235 */
236 static String _convertKeyCodeToKeyName(int keyCode) {
237 switch(keyCode) {
238 case KeyCode.ALT: return _KeyName.ALT;
239 case KeyCode.BACKSPACE: return _KeyName.BACKSPACE;
240 case KeyCode.CAPS_LOCK: return _KeyName.CAPS_LOCK;
241 case KeyCode.CTRL: return _KeyName.CONTROL;
242 case KeyCode.DELETE: return _KeyName.DEL;
243 case KeyCode.DOWN: return _KeyName.DOWN;
244 case KeyCode.END: return _KeyName.END;
245 case KeyCode.ENTER: return _KeyName.ENTER;
246 case KeyCode.ESC: return _KeyName.ESC;
247 case KeyCode.F1: return _KeyName.F1;
248 case KeyCode.F2: return _KeyName.F2;
249 case KeyCode.F3: return _KeyName.F3;
250 case KeyCode.F4: return _KeyName.F4;
251 case KeyCode.F5: return _KeyName.F5;
252 case KeyCode.F6: return _KeyName.F6;
253 case KeyCode.F7: return _KeyName.F7;
254 case KeyCode.F8: return _KeyName.F8;
255 case KeyCode.F9: return _KeyName.F9;
256 case KeyCode.F10: return _KeyName.F10;
257 case KeyCode.F11: return _KeyName.F11;
258 case KeyCode.F12: return _KeyName.F12;
259 case KeyCode.HOME: return _KeyName.HOME;
260 case KeyCode.INSERT: return _KeyName.INSERT;
261 case KeyCode.LEFT: return _KeyName.LEFT;
262 case KeyCode.META: return _KeyName.META;
263 case KeyCode.NUMLOCK: return _KeyName.NUM_LOCK;
264 case KeyCode.PAGE_DOWN: return _KeyName.PAGE_DOWN;
265 case KeyCode.PAGE_UP: return _KeyName.PAGE_UP;
266 case KeyCode.PAUSE: return _KeyName.PAUSE;
267 case KeyCode.PRINT_SCREEN: return _KeyName.PRINT_SCREEN;
268 case KeyCode.RIGHT: return _KeyName.RIGHT;
269 case KeyCode.SCROLL_LOCK: return _KeyName.SCROLL;
270 case KeyCode.SHIFT: return _KeyName.SHIFT;
271 case KeyCode.SPACE: return _KeyName.SPACEBAR;
272 case KeyCode.TAB: return _KeyName.TAB;
273 case KeyCode.UP: return _KeyName.UP;
274 case KeyCode.WIN_IME:
275 case KeyCode.WIN_KEY:
276 case KeyCode.WIN_KEY_LEFT:
277 case KeyCode.WIN_KEY_RIGHT:
278 return _KeyName.WIN;
279 default: return _KeyName.UNIDENTIFIED;
280 }
281 return _KeyName.UNIDENTIFIED;
282 }
228 } 283 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698