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

Unified Diff: chrome/browser/resources/chromeos/keyboard_overlay.js

Issue 11415124: Add keyboard overlay help for the Search key as a Function key extended keyboard shortcuts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/chromeos/keyboard_overlay.js
diff --git a/chrome/browser/resources/chromeos/keyboard_overlay.js b/chrome/browser/resources/chromeos/keyboard_overlay.js
index a8ccd1f472b193c949ef9ce9d2a271255f62d9dd..0d802181ac45fd35554f9d29e0b71ba462036c57 100644
--- a/chrome/browser/resources/chromeos/keyboard_overlay.js
+++ b/chrome/browser/resources/chromeos/keyboard_overlay.js
@@ -22,13 +22,15 @@ var BASE_INSTRUCTIONS = {
var MODIFIER_TO_CLASS = {
'SHIFT': 'modifier-shift',
'CTRL': 'modifier-ctrl',
- 'ALT': 'modifier-alt'
+ 'ALT': 'modifier-alt',
+ 'SEARCH': 'modifier-search'
};
var IDENTIFIER_TO_CLASS = {
'2A': 'is-shift',
'1D': 'is-ctrl',
- '38': 'is-alt'
+ '38': 'is-alt',
+ 'E0 5B': 'is-search'
};
var LABEL_TO_IDENTIFIER = {
@@ -121,7 +123,16 @@ function getLayouts() {
* @return {Object} Keyboard shortcut data.
*/
function getShortcutData() {
- return keyboardOverlayData['shortcut'];
+ var data = keyboardOverlayData['shortcut'];
+
+ var searchKeyIsModifier =
+ loadTimeData.getString('keyboardSearchKeyActsAsFunctionKey') == 'true';
+ var mergeData = searchKeyIsModifier ?
+ keyboardOverlayData['searchModifierShortcuts'] :
+ keyboardOverlayData['noSearchModifierShortcuts'];
+ for (var key in mergeData)
+ data[key] = mergeData[key];
+ return data;
}
/**
@@ -163,6 +174,8 @@ function hex2char(hex) {
return result;
}
+var searchIsPressed = false;
+
/**
* Returns a list of modifiers from the key event.
* @param {Event} e The key event.
@@ -177,17 +190,22 @@ function getModifiers(e) {
16: 'SHIFT',
17: 'CTRL',
18: 'ALT',
+ 91: 'SEARCH',
};
var modifierWithKeyCode = keyCodeToModifier[e.keyCode];
- var isPressed = {'SHIFT': e.shiftKey, 'CTRL': e.ctrlKey, 'ALT': e.altKey};
- // if e.keyCode is one of Shift, Ctrl and Alt, isPressed should
- // be changed because the key currently pressed
- // does not affect the values of e.shiftKey, e.ctrlKey and e.altKey
+ var isPressed = {
+ 'SHIFT': e.shiftKey,
+ 'CTRL': e.ctrlKey,
+ 'ALT': e.altKey,
+ 'SEARCH': searchIsPressed
+ };
if (modifierWithKeyCode)
isPressed[modifierWithKeyCode] = isKeyDown;
+ searchIsPressed = isPressed['SEARCH'];
+
// make the result array
- return ['SHIFT', 'CTRL', 'ALT'].filter(
+ return ['SHIFT', 'CTRL', 'ALT', 'SEARCH'].filter(
function(modifier) {
return isPressed[modifier];
}).sort();
@@ -248,7 +266,8 @@ function getKeyClasses(identifier, modifiers) {
if ((identifier == '2A' && contains(modifiers, 'SHIFT')) ||
(identifier == '1D' && contains(modifiers, 'CTRL')) ||
- (identifier == '38' && contains(modifiers, 'ALT'))) {
+ (identifier == '38' && contains(modifiers, 'ALT')) ||
+ (identifier == 'E0 5B' && contains(modifiers, 'SEARCH'))) {
classes.push('pressed');
classes.push(IDENTIFIER_TO_CLASS[identifier]);
}
@@ -512,11 +531,18 @@ function initLayout() {
instructions.style.height = (height * BASE_INSTRUCTIONS.height /
BASE_KEYBOARD.height) + 'px';
+ var searchKeyIsModifier =
mazda 2012/11/28 05:25:18 Please move this just before line 540.
danakj 2012/11/28 21:11:24 Done.
+ loadTimeData.getString('keyboardSearchKeyActsAsFunctionKey') == 'true';
+
var instructionsText = document.createElement('div');
instructionsText.id = 'instructions-text';
instructionsText.className = 'keyboard-overlay-instructions-text';
- instructionsText.innerHTML =
- loadTimeData.getString('keyboardOverlayInstructions');
+ if (searchKeyIsModifier)
mazda 2012/11/28 05:25:18 if (searchKeyIsModifier) { ... } else { ... }
danakj 2012/11/28 21:11:24 Done.
+ instructionsText.innerHTML =
+ loadTimeData.getString('keyboardOverlayInstructionsWithSearch');
+ else
+ instructionsText.innerHTML =
+ loadTimeData.getString('keyboardOverlayInstructions');
instructions.appendChild(instructionsText);
var instructionsHideText = document.createElement('div');
instructionsHideText.id = 'instructions-hide-text';

Powered by Google App Engine
This is Rietveld 408576698