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

Side by Side Diff: chrome/common/extensions/docs/examples/extensions/speak_selection/keycodes.js

Issue 8114011: Add sample extensions that use the text-to-speech (TTS) API. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 var KEY_MAP = {
2 12: 'Clear',
3 14: 'Enter',
4 33: 'PgUp',
5 34: 'PgDown',
6 35: 'End',
7 36: 'Home',
8 37: 'Left',
9 38: 'Up',
10 39: 'Right',
11 40: 'Down',
12 45: 'Insert',
13 46: 'Delete',
14 96: 'Numpad0',
15 97: 'Numpad1',
16 98: 'Numpad2',
17 99: 'Numpad3',
18 100: 'Numpad4',
19 101: 'Numpad5',
20 102: 'Numpad6',
21 103: 'Numpad7',
22 104: 'Numpad8',
23 105: 'Numpad9',
24 106: '*',
25 107: 'Plus',
26 108: '_',
27 109: '-',
28 111: '/',
29 112: 'F1',
30 113: 'F2',
31 114: 'F3',
32 115: 'F4',
33 116: 'F5',
34 117: 'F6',
35 118: 'F7',
36 119: 'F8',
37 120: 'F9',
38 121: 'F10',
39 122: 'F11',
40 123: 'F12',
41 124: 'F13',
42 125: 'F14',
43 126: 'F15',
44 186: ';',
45 187: '=',
46 188: ',',
47 189: '-',
48 190: '.',
49 191: '/',
50 192: '`',
51 219: '[',
52 221: ']'
53 };
54
55 var isMac = (navigator.appVersion.indexOf("Mac") != -1);
56
57 function keyEventToString(evt) {
58 var tokens = [];
59 if (evt.ctrlKey) {
60 tokens.push('Control');
61 }
62 if (evt.altKey) {
63 tokens.push(isMac ? 'Option' : 'Alt');
64 }
65 if (evt.metaKey) {
66 tokens.push(isMac ? 'Command' : 'Meta');
67 }
68 if (evt.shiftKey) {
69 tokens.push('Shift');
70 }
71 if (evt.keyCode >= 48 && evt.keyCode <= 90) {
72 tokens.push(String.fromCharCode(evt.keyCode));
73 } else if (KEY_MAP[evt.keyCode]) {
74 tokens.push(KEY_MAP[evt.keyCode]);
75 } else {
76 return '';
77 }
78 return tokens.join('+');
79 }
80
81 function getDefaultKeyString() {
82 return keyEventToString({
83 keyCode: 83, // 's'
84 shiftKey: true,
85 altKey: true,
86 ctrlKey: true,
87 metaKey: false});
88 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698