| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 A collection of JavaScript utilities used to simplify working | 6 * @fileoverview A collection of JavaScript utilities used to simplify working |
| 7 * with keyboard events. | 7 * with keyboard events. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 | 10 |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 */ | 335 */ |
| 336 cvox.KeyUtil.getStickyKeyCode = function() { | 336 cvox.KeyUtil.getStickyKeyCode = function() { |
| 337 // TODO (rshearer): This should not be hard-coded here. | 337 // TODO (rshearer): This should not be hard-coded here. |
| 338 var stickyKeyCode = 45; // Insert for Linux and Windows | 338 var stickyKeyCode = 45; // Insert for Linux and Windows |
| 339 if (cvox.ChromeVox.isChromeOS || cvox.ChromeVox.isMac) { | 339 if (cvox.ChromeVox.isChromeOS || cvox.ChromeVox.isMac) { |
| 340 stickyKeyCode = 91; // GUI key (Search/Cmd) for ChromeOs and Mac | 340 stickyKeyCode = 91; // GUI key (Search/Cmd) for ChromeOs and Mac |
| 341 } | 341 } |
| 342 return stickyKeyCode; | 342 return stickyKeyCode; |
| 343 }; | 343 }; |
| 344 | 344 |
| 345 /** | |
| 346 * Get the platform specific sticky key KeySequence. Creates the KeySequence | |
| 347 * object if it doesn't already exist. | |
| 348 * | |
| 349 * @return {cvox.KeySequence} The platform specific sticky key KeySequence. | |
| 350 */ | |
| 351 cvox.KeyUtil.getStickyKeySequence = function() { | |
| 352 if (cvox.KeyUtil.stickyKeySequence == null) { | |
| 353 var stickyKeyCode = cvox.KeyUtil.getStickyKeyCode(); | |
| 354 var stickyKeyObj = {keyCode: stickyKeyCode, stickyMode: true}; | |
| 355 var stickyKeySequence = new cvox.KeySequence(stickyKeyObj); | |
| 356 stickyKeySequence.addKeyEvent(stickyKeyObj); | |
| 357 cvox.KeyUtil.stickyKeySequence = stickyKeySequence; | |
| 358 } | |
| 359 return cvox.KeyUtil.stickyKeySequence; | |
| 360 }; | |
| 361 | |
| 362 | 345 |
| 363 /** | 346 /** |
| 364 * Get readable string description for an internal string representation of a | 347 * Get readable string description for an internal string representation of a |
| 365 * key or a keyboard shortcut. | 348 * key or a keyboard shortcut. |
| 366 * | 349 * |
| 367 * @param {string} keyStr The internal string repsentation of a key or | 350 * @param {string} keyStr The internal string repsentation of a key or |
| 368 * a keyboard shortcut. | 351 * a keyboard shortcut. |
| 369 * @return {?string} Readable string representation of the input. | 352 * @return {?string} Readable string representation of the input. |
| 370 */ | 353 */ |
| 371 cvox.KeyUtil.getReadableNameForStr = function(keyStr) { | 354 cvox.KeyUtil.getReadableNameForStr = function(keyStr) { |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 key.doubleTap = true; | 483 key.doubleTap = true; |
| 501 for (var i = 0, keySeq; keySeq = cvox.KeySequence.doubleTapCache[i]; i++) { | 484 for (var i = 0, keySeq; keySeq = cvox.KeySequence.doubleTapCache[i]; i++) { |
| 502 if (keySeq.equals(key)) { | 485 if (keySeq.equals(key)) { |
| 503 isSet = true; | 486 isSet = true; |
| 504 break; | 487 break; |
| 505 } | 488 } |
| 506 } | 489 } |
| 507 key.doubleTap = originalState; | 490 key.doubleTap = originalState; |
| 508 return isSet; | 491 return isSet; |
| 509 }; | 492 }; |
| OLD | NEW |