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

Side by Side Diff: chrome/browser/resources/chromeos/keyboard_overlay.js

Issue 10825026: Make accelerators not to work when the keyboard overlay is shown. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 8 years, 4 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
« no previous file with comments | « ash/wm/partial_screenshot_view.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <include src="keyboard_overlay_data.js"/> 5 <include src="keyboard_overlay_data.js"/>
6 <include src="keyboard_overlay_accessibility_helper.js"/> 6 <include src="keyboard_overlay_accessibility_helper.js"/>
7 7
8 var BASE_KEYBOARD = { 8 var BASE_KEYBOARD = {
9 top: 0, 9 top: 0,
10 left: 0, 10 left: 0,
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 } 301 }
302 if (isAscii(keyLabel) && 302 if (isAscii(keyLabel) &&
303 getShortcutData()[getAction(keyLabel, modifiers)]) { 303 getShortcutData()[getAction(keyLabel, modifiers)]) {
304 break; 304 break;
305 } 305 }
306 } 306 }
307 return keyLabel; 307 return keyLabel;
308 } 308 }
309 309
310 /** 310 /**
311 * Returns the label corresponding to the key code.
312 * @param {string} keyCode Key code
313 * @return {string} Label of the key code.
314 */
315 function getKeyLabelFromKeyCode(keyCode) {
316 if ('0'.charCodeAt(0) <= keyCode && keyCode <= 'Z'.charCodeAt(0))
317 return String.fromCharCode(keyCode).toLowerCase();
318 var label = KEYCODE_TO_LABEL[keyCode];
319 if (label)
320 return label;
321 return '';
322 }
323
324 /**
325 * Returns a normalized string used for a key of shortcutData. 311 * Returns a normalized string used for a key of shortcutData.
326 * 312 *
327 * Examples: 313 * Examples:
328 * keyCode: 'd', modifiers: ['CTRL', 'SHIFT'] => 'd<>CTRL<>SHIFT' 314 * keyCode: 'd', modifiers: ['CTRL', 'SHIFT'] => 'd<>CTRL<>SHIFT'
329 * keyCode: 'alt', modifiers: ['ALT', 'SHIFT'] => 'ALT<>SHIFT' 315 * keyCode: 'alt', modifiers: ['ALT', 'SHIFT'] => 'ALT<>SHIFT'
330 * 316 *
331 * @param {string} keyCode Key code. 317 * @param {string} keyCode Key code.
332 * @param {Array} modifiers Key Modifier list. 318 * @param {Array} modifiers Key Modifier list.
333 * @return {string} Normalized key shortcut data string. 319 * @return {string} Normalized key shortcut data string.
334 */ 320 */
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 } 427 }
442 428
443 /** 429 /**
444 * A callback function for onkeydown and onkeyup events. 430 * A callback function for onkeydown and onkeyup events.
445 * @param {Event} e Key event. 431 * @param {Event} e Key event.
446 */ 432 */
447 function handleKeyEvent(e) { 433 function handleKeyEvent(e) {
448 if (!getKeyboardOverlayId()) { 434 if (!getKeyboardOverlayId()) {
449 return; 435 return;
450 } 436 }
451 var label = getKeyLabelFromKeyCode(e.keyCode);
452 var modifiers = getModifiers(e); 437 var modifiers = getModifiers(e);
453 var shortcutData = getShortcutData();
454 var action = getAction(label, modifiers);
455 if (e.type == 'keydown' &&
456 (contains(CLOSE_LABELS, label) || shortcutData[action])) {
457 chrome.send('DialogClose');
458 return;
459 }
460 update(modifiers); 438 update(modifiers);
461 KeyboardOverlayAccessibilityHelper.maybeSpeakAllShortcuts(modifiers); 439 KeyboardOverlayAccessibilityHelper.maybeSpeakAllShortcuts(modifiers);
462 e.preventDefault(); 440 e.preventDefault();
463 } 441 }
464 442
465 /** 443 /**
466 * Initializes the layout of the keys. 444 * Initializes the layout of the keys.
467 */ 445 */
468 function initLayout() { 446 function initLayout() {
469 // Add data for the caps lock key 447 // Add data for the caps lock key
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 * Handles click events of the learn more link. 601 * Handles click events of the learn more link.
624 * @param {Event} e Mouse click event. 602 * @param {Event} e Mouse click event.
625 */ 603 */
626 function learnMoreClicked(e) { 604 function learnMoreClicked(e) {
627 chrome.send('openLearnMorePage'); 605 chrome.send('openLearnMorePage');
628 chrome.send('DialogClose'); 606 chrome.send('DialogClose');
629 e.preventDefault(); 607 e.preventDefault();
630 } 608 }
631 609
632 document.addEventListener('DOMContentLoaded', init); 610 document.addEventListener('DOMContentLoaded', init);
OLDNEW
« no previous file with comments | « ash/wm/partial_screenshot_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698