diff options
author | hashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-16 09:11:51 +0000 |
---|---|---|
committer | hashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-16 09:11:51 +0000 |
commit | 70ec2225b0058cb0402502b05384c1b1f8a99b6a (patch) | |
tree | 230c594b12b108d30b5a9808ec2f00d055744dc9 | |
parent | a5c2477b59b6dbc3a75a482b08fd040294922ddd (diff) | |
download | chromium_src-70ec2225b0058cb0402502b05384c1b1f8a99b6a.zip chromium_src-70ec2225b0058cb0402502b05384c1b1f8a99b6a.tar.gz chromium_src-70ec2225b0058cb0402502b05384c1b1f8a99b6a.tar.bz2 |
Make keyboard overlay speak when ChromeVox is active
Pressing modifier keys will speak all the shortcuts with the modifier
BUG=chromium-os:16603
TEST=Enable accessibility. Press Ctrl+Alt+/ to show keyboard overlay. Press modifier keys and ensure it speaks.
Review URL: http://codereview.chromium.org/7628018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96909 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/resources/keyboard_overlay.html | 1 | ||||
-rw-r--r-- | chrome/browser/resources/keyboard_overlay.js | 1 | ||||
-rw-r--r-- | chrome/browser/resources/keyboard_overlay_accessibility_helper.js | 40 |
3 files changed, 42 insertions, 0 deletions
diff --git a/chrome/browser/resources/keyboard_overlay.html b/chrome/browser/resources/keyboard_overlay.html index 9724f6a..f20ed06 100644 --- a/chrome/browser/resources/keyboard_overlay.html +++ b/chrome/browser/resources/keyboard_overlay.html @@ -5,6 +5,7 @@ <title i18n-content="keyboardOverlayTitle"></title> <link rel="stylesheet" href="keyboard_overlay.css"> <script src="keyboard_overlay_data.js"></script> +<script src="keyboard_overlay_accessibility_helper.js"></script> <script src="keyboard_overlay.js"></script> <body class="keyboard-overlay-keyboard"></body> </html> diff --git a/chrome/browser/resources/keyboard_overlay.js b/chrome/browser/resources/keyboard_overlay.js index d73caaf..aa8631f 100644 --- a/chrome/browser/resources/keyboard_overlay.js +++ b/chrome/browser/resources/keyboard_overlay.js @@ -319,6 +319,7 @@ function handleKeyEvent(e){ return; } update(modifiers); + KeyboardOverlayAccessibilityHelper.maybeSpeakAllShortcuts(modifiers); } /** diff --git a/chrome/browser/resources/keyboard_overlay_accessibility_helper.js b/chrome/browser/resources/keyboard_overlay_accessibility_helper.js new file mode 100644 index 0000000..c28a500 --- /dev/null +++ b/chrome/browser/resources/keyboard_overlay_accessibility_helper.js @@ -0,0 +1,40 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// An object to implement keyboard overlay accessiblity. +var KeyboardOverlayAccessibilityHelper = { + // Returns true when ChromeVox is loaded and active, false otherwise. + cvoxIsActive: function() { + return window.cvox && window.cvox.Api.isChromeVoxActive(); + }, + // Speaks all the shortcut with the given modifiers. + maybeSpeakAllShortcuts: function(modifiers) { + if (!this.cvoxIsActive()) + return; + cvox.Api.stop(); + var keyboardGlyphData = getKeyboardGlyphData(); + var shortcutData = getShortcutData(); + var layout = getLayouts()[keyboardGlyphData.layoutName]; + var keysToShortcutText = {}; + for (var i = 0; i < layout.length; ++i) { + var identifier = remapIdentifier(layout[i][0]); + var keyData = keyboardGlyphData.keys[identifier]; + var keyLabel = getKeyLabel(keyData, modifiers); + var shortcutId = shortcutData[getAction(keyLabel, modifiers)]; + var shortcutText = templateData[shortcutId]; + var keysText = modifiers.concat(keyLabel).join(' + '); + if (shortcutText) + keysToShortcutText[keysText] = shortcutText; + } + for (var keysText in keysToShortcutText) { + this.speakShortcut_(keysText, keysToShortcutText[keysText]); + } + }, + // Speaks given shortcut description. + speakShortcut_: function(keysText, shortcutText) { + keysText = keysText.toLowerCase(); // For correct pronunciation. + cvox.Api.speak(keysText, 1, {}); + cvox.Api.speak(shortcutText, 1, {}); + }, +}; |