1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // An object to implement keyboard overlay accessiblity.
6 var KeyboardOverlayAccessibilityHelper = {
7 // Returns true when ChromeVox is loaded and active, false otherwise.
8 cvoxIsActive: function() {
9 return window.cvox && window.cvox.Api.isChromeVoxActive();
11 // Speaks all the shortcut with the given modifiers.
12 maybeSpeakAllShortcuts: function(modifiers) {
13 if (!this.cvoxIsActive())
16 var keyboardGlyphData = getKeyboardGlyphData();
17 var shortcutData = getShortcutData();
18 var layout = getLayouts()[keyboardGlyphData.layoutName];
19 var keysToShortcutText = {};
20 for (var i = 0; i < layout.length; ++i) {
21 var identifier = remapIdentifier(layout[i][0]);
22 var keyData = keyboardGlyphData.keys[identifier];
23 var keyLabel = getKeyLabel(keyData, modifiers);
24 var shortcutId = shortcutData[getAction(keyLabel, modifiers)];
25 var shortcutText = templateData[shortcutId];
26 var keysText = modifiers.concat(keyLabel).join(' + ');
28 keysToShortcutText[keysText] = shortcutText;
30 for (var keysText in keysToShortcutText) {
31 this.speakShortcut_(keysText, keysToShortcutText[keysText]);
34 // Speaks given shortcut description.
35 speakShortcut_: function(keysText, shortcutText) {
36 keysText = keysText.toLowerCase(); // For correct pronunciation.
37 cvox.Api.speak(keysText, 1, {});
38 cvox.Api.speak(shortcutText, 1, {});