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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/examples/extensions/speak_selection/keycodes.js
===================================================================
--- chrome/common/extensions/docs/examples/extensions/speak_selection/keycodes.js (revision 0)
+++ chrome/common/extensions/docs/examples/extensions/speak_selection/keycodes.js (revision 0)
@@ -0,0 +1,88 @@
+var KEY_MAP = {
+ 12: 'Clear',
+ 14: 'Enter',
+ 33: 'PgUp',
+ 34: 'PgDown',
+ 35: 'End',
+ 36: 'Home',
+ 37: 'Left',
+ 38: 'Up',
+ 39: 'Right',
+ 40: 'Down',
+ 45: 'Insert',
+ 46: 'Delete',
+ 96: 'Numpad0',
+ 97: 'Numpad1',
+ 98: 'Numpad2',
+ 99: 'Numpad3',
+ 100: 'Numpad4',
+ 101: 'Numpad5',
+ 102: 'Numpad6',
+ 103: 'Numpad7',
+ 104: 'Numpad8',
+ 105: 'Numpad9',
+ 106: '*',
+ 107: 'Plus',
+ 108: '_',
+ 109: '-',
+ 111: '/',
+ 112: 'F1',
+ 113: 'F2',
+ 114: 'F3',
+ 115: 'F4',
+ 116: 'F5',
+ 117: 'F6',
+ 118: 'F7',
+ 119: 'F8',
+ 120: 'F9',
+ 121: 'F10',
+ 122: 'F11',
+ 123: 'F12',
+ 124: 'F13',
+ 125: 'F14',
+ 126: 'F15',
+ 186: ';',
+ 187: '=',
+ 188: ',',
+ 189: '-',
+ 190: '.',
+ 191: '/',
+ 192: '`',
+ 219: '[',
+ 221: ']'
+};
+
+var isMac = (navigator.appVersion.indexOf("Mac") != -1);
+
+function keyEventToString(evt) {
+ var tokens = [];
+ if (evt.ctrlKey) {
+ tokens.push('Control');
+ }
+ if (evt.altKey) {
+ tokens.push(isMac ? 'Option' : 'Alt');
+ }
+ if (evt.metaKey) {
+ tokens.push(isMac ? 'Command' : 'Meta');
+ }
+ if (evt.shiftKey) {
+ tokens.push('Shift');
+ }
+ if (evt.keyCode >= 48 && evt.keyCode <= 90) {
+ tokens.push(String.fromCharCode(evt.keyCode));
+ } else if (KEY_MAP[evt.keyCode]) {
+ tokens.push(KEY_MAP[evt.keyCode]);
+ } else {
+ return '';
+ }
+ return tokens.join('+');
+}
+
+function getDefaultKeyString() {
+ return keyEventToString({
+ keyCode: 83, // 's'
+ shiftKey: true,
+ altKey: true,
+ ctrlKey: true,
+ metaKey: false});
+}
Property changes on: chrome/common/extensions/docs/examples/extensions/speak_selection/keycodes.js
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698