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

Side by Side Diff: chrome/browser/resources/chromeos/switch_access/keyboard_handler.js

Issue 2905373002: Set keys for SwitchAccessEventHandler to capture using accessibiltyPrivate API (Closed)
Patch Set: Updated extension histograms Created 3 years, 6 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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // TODO(elichtenberg): Move into custom logger class or somewhere else. 5 // TODO(elichtenberg): Move into custom logger class or somewhere else.
6 let debuggingEnabled = true; 6 let debuggingEnabled = true;
7 7
8 /** 8 /**
9 * Class to handle keyboard input. 9 * Class to handle keyboard input.
10 * 10 *
(...skipping 10 matching lines...) Expand all
21 this.init_(); 21 this.init_();
22 }; 22 };
23 23
24 KeyboardHandler.prototype = { 24 KeyboardHandler.prototype = {
25 /** 25 /**
26 * Set up key listener. 26 * Set up key listener.
27 * 27 *
28 * @private 28 * @private
29 */ 29 */
30 init_: function() { 30 init_: function() {
31 // Capture keycodes for keys 1 through 4, and 6 through 9.
32 chrome.accessibilityPrivate.setSwitchAccessKeys(
33 [49, 50, 51, 52, 54, 55, 56, 57]);
David Tseng 2017/05/26 22:10:31 Use ''.charCodeAt rather than hard coding the key
elichtenberg 2017/05/27 00:13:04 Done.
31 document.addEventListener('keyup', this.handleKeyEvent_.bind(this)); 34 document.addEventListener('keyup', this.handleKeyEvent_.bind(this));
32 }, 35 },
33 36
34 /** 37 /**
35 * Handle a keyboard event by calling the appropriate SwitchAccess functions. 38 * Handle a keyboard event by calling the appropriate SwitchAccess functions.
36 * 39 *
37 * @param {!Event} event 40 * @param {!Event} event
38 * @private 41 * @private
39 */ 42 */
40 handleKeyEvent_: function(event) { 43 handleKeyEvent_: function(event) {
(...skipping 30 matching lines...) Expand all
71 break; 74 break;
72 case '9': 75 case '9':
73 console.log('9 = go to parent element (debug mode)'); 76 console.log('9 = go to parent element (debug mode)');
74 this.switchAccess_.debugMoveToParent(); 77 this.switchAccess_.debugMoveToParent();
75 break; 78 break;
76 } 79 }
77 } 80 }
78 this.switchAccess_.performedUserAction(); 81 this.switchAccess_.performedUserAction();
79 } 82 }
80 }; 83 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698