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

Side by Side Diff: chrome/browser/resources/chromeos/keyboard/keyboard_utils.js

Issue 2751523010: cros: Fix hotrod remote arrow keys not working on gaia for CFM oobe (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « no previous file | 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 * Namespace for keyboard utility functions. 6 * Namespace for keyboard utility functions.
7 */ 7 */
8 var keyboard = {}; 8 var keyboard = {};
9 9
10 /** 10 /**
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 }; 45 };
46 46
47 /** 47 /**
48 * Swallows keypress and keyup events of arrow keys. 48 * Swallows keypress and keyup events of arrow keys.
49 * @param {!Event} event Raised event. 49 * @param {!Event} event Raised event.
50 * @private 50 * @private
51 */ 51 */
52 keyboard.onKeyIgnore_ = function(event) { 52 keyboard.onKeyIgnore_ = function(event) {
53 event = /** @type {!KeyboardEvent} */(event); 53 event = /** @type {!KeyboardEvent} */(event);
54 54
55 if (hasKeyModifiers(event)) 55 if (event.ctrlKey || event.shiftKey || event.altKey || event.metaKey)
56 return; 56 return;
57 57
58 if (event.key == 'ArrowLeft' || 58 if (event.key == 'ArrowLeft' ||
59 event.key == 'ArrowRight' || 59 event.key == 'ArrowRight' ||
60 event.key == 'ArrowUp' || 60 event.key == 'ArrowUp' ||
61 event.key == 'ArrowDown') { 61 event.key == 'ArrowDown') {
62 event.stopPropagation(); 62 event.stopPropagation();
63 event.preventDefault(); 63 event.preventDefault();
64 } 64 }
65 }; 65 };
66 66
67 /** 67 /**
68 * Handles arrow key events, depending on if self is a content script. 68 * Handles arrow key events, depending on if self is a content script.
69 * @param {!Event} event Raised event. 69 * @param {!Event} event Raised event.
70 * @private 70 * @private
71 */ 71 */
72 keyboard.onKeyDown_ = function(event) { 72 keyboard.onKeyDown_ = function(event) {
73 event = /** @type {!KeyboardEvent} */(event); 73 event = /** @type {!KeyboardEvent} */(event);
74 74
75 if (hasKeyModifiers(event)) 75 if (event.ctrlKey || event.shiftKey || event.altKey || event.metaKey)
76 return; 76 return;
77 77
78 // This file also gets embedded inside of the CfM/hotrod enrollment webview. 78 // This file also gets embedded inside of the CfM/hotrod enrollment webview.
79 // Events will bubble down into the webview, which means that the event 79 // Events will bubble down into the webview, which means that the event
80 // handler from the webui will steal the events meant for the webview. So we 80 // handler from the webui will steal the events meant for the webview. So we
81 // have to disable the webui handler if the active element is the webview. 81 // have to disable the webui handler if the active element is the webview.
82 // 82 //
83 // $ is defined differently depending on how this file gets executed; we have 83 // $ is defined differently depending on how this file gets executed; we have
84 // to use document.getElementById to get consistent behavior. 84 // to use document.getElementById to get consistent behavior.
85 // 85 //
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 keyboard.initializeKeyboardFlow = function(injected) { 130 keyboard.initializeKeyboardFlow = function(injected) {
131 document.addEventListener('keydown', 131 document.addEventListener('keydown',
132 keyboard.onKeyDown_, true); 132 keyboard.onKeyDown_, true);
133 document.addEventListener('keypress', 133 document.addEventListener('keypress',
134 keyboard.onKeyIgnore_, true); 134 keyboard.onKeyIgnore_, true);
135 document.addEventListener('keyup', 135 document.addEventListener('keyup',
136 keyboard.onKeyIgnore_, true); 136 keyboard.onKeyIgnore_, true);
137 if (injected) 137 if (injected)
138 window.addEventListener('message', keyboard.onInitMessage_); 138 window.addEventListener('message', keyboard.onInitMessage_);
139 }; 139 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698