| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 /** | 5 /** |
| 6 * @fileoverview ChromeVox keyboard handler. | 6 * @fileoverview ChromeVox keyboard handler. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 goog.provide('BackgroundKeyboardHandler'); | 9 goog.provide('BackgroundKeyboardHandler'); |
| 10 | 10 |
| 11 goog.require('cvox.ChromeVoxKbHandler'); | 11 goog.require('cvox.ChromeVoxKbHandler'); |
| 12 | 12 |
| 13 /** @constructor */ | 13 /** @constructor */ |
| 14 BackgroundKeyboardHandler = function() { | 14 BackgroundKeyboardHandler = function() { |
| 15 // Classic keymap. | 15 // Classic keymap. |
| 16 cvox.ChromeVoxKbHandler.handlerKeyMap = cvox.KeyMap.fromDefaults(); | 16 cvox.ChromeVoxKbHandler.handlerKeyMap = cvox.KeyMap.fromDefaults(); |
| 17 | 17 |
| 18 /** @type {number} @private */ | 18 /** @type {number} @private */ |
| 19 this.passThroughKeyUpCount_ = 0; | 19 this.passThroughKeyUpCount_ = 0; |
| 20 | 20 |
| 21 /** @type {Set} @private */ | 21 /** @type {Set} @private */ |
| 22 this.eatenKeyDowns_ = new Set(); | 22 this.eatenKeyDowns_ = new Set(); |
| 23 | 23 |
| 24 document.addEventListener('keydown', this.onKeyDown.bind(this), false); | 24 document.addEventListener('keydown', this.onKeyDown.bind(this), false); |
| 25 document.addEventListener('keyup', this.onKeyUp.bind(this), false); | 25 document.addEventListener('keyup', this.onKeyUp.bind(this), false); |
| 26 |
| 27 chrome.accessibilityPrivate.setKeyboardListener(true, false); |
| 26 }; | 28 }; |
| 27 | 29 |
| 28 BackgroundKeyboardHandler.prototype = { | 30 BackgroundKeyboardHandler.prototype = { |
| 29 /** | 31 /** |
| 30 * Handles key down events. | 32 * Handles key down events. |
| 31 * @param {Event} evt The key down event to process. | 33 * @param {Event} evt The key down event to process. |
| 32 * @return {boolean} True if the default action should be performed. | 34 * @return {boolean} True if the default action should be performed. |
| 33 */ | 35 */ |
| 34 onKeyDown: function(evt) { | 36 onKeyDown: function(evt) { |
| 35 evt.stickyMode = cvox.ChromeVox.isStickyModeOn() && cvox.ChromeVox.isActive; | 37 evt.stickyMode = cvox.ChromeVox.isStickyModeOn() && cvox.ChromeVox.isActive; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 window['prefs'].switchToKeyMap('keymap_next'); | 97 window['prefs'].switchToKeyMap('keymap_next'); |
| 96 } else if (oldMode && | 98 } else if (oldMode && |
| 97 oldMode != ChromeVoxMode.CLASSIC && | 99 oldMode != ChromeVoxMode.CLASSIC && |
| 98 oldMode != ChromeVoxMode.CLASSIC_COMPAT) { | 100 oldMode != ChromeVoxMode.CLASSIC_COMPAT) { |
| 99 // Switching out of next. Intentionally do nothing when switching out of | 101 // Switching out of next. Intentionally do nothing when switching out of |
| 100 // an uninitialized |oldMode|. | 102 // an uninitialized |oldMode|. |
| 101 window['prefs'].switchToKeyMap('keymap_classic'); | 103 window['prefs'].switchToKeyMap('keymap_classic'); |
| 102 } | 104 } |
| 103 } | 105 } |
| 104 }; | 106 }; |
| OLD | NEW |