blob: 730f6e7517c6e0a8e9a5b7e4f2b7f411abdc6234 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
// Copyright 2014 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.
/**
* @fileoverview Script for ChromeOS keyboard explorer.
*
*/
goog.provide('cvox.KbExplorer');
goog.require('cvox.KeyUtil');
/**
* Class to manage the keyboard explorer.
* @constructor
*/
cvox.KbExplorer = function() { };
/**
* Initialize keyboard explorer.
*/
cvox.KbExplorer.init = function() {
document.addEventListener('keydown', cvox.KbExplorer.onKeyDown, false);
document.addEventListener('keyup', cvox.KbExplorer.onKeyUp, false);
document.addEventListener('keypress', cvox.KbExplorer.onKeyPress, false);
};
/**
* Handles keydown events by speaking the human understandable name of the key.
* @param {Event} evt key event.
*/
cvox.KbExplorer.onKeyDown = function(evt) {
chrome.extension.getBackgroundPage()['speak'](
cvox.KeyUtil.getReadableNameForKeyCode(evt.keyCode), false, {});
evt.preventDefault();
evt.stopPropagation();
};
/**
* Handles keyup events.
* @param {Event} evt key event.
*/
cvox.KbExplorer.onKeyUp = function(evt) {
evt.preventDefault();
evt.stopPropagation();
};
/**
* Handles keypress events.
* @param {Event} evt key event.
*/
cvox.KbExplorer.onKeyPress = function(evt) {
evt.preventDefault();
evt.stopPropagation();
};
|