| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 * @fileoverview A simple virtual keyboard implementation. | 6 * @fileoverview A simple virtual keyboard implementation. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 var KEY_MODE = 'key'; | 9 var KEY_MODE = 'key'; |
| 10 var SHIFT_MODE = 'shift'; | 10 var SHIFT_MODE = 'shift'; |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 * Send the given key to chrome, via the experimental extension API. | 132 * Send the given key to chrome, via the experimental extension API. |
| 133 * @param {string} key The key to send. | 133 * @param {string} key The key to send. |
| 134 * @return {void} | 134 * @return {void} |
| 135 */ | 135 */ |
| 136 function sendKey(key) { | 136 function sendKey(key) { |
| 137 var keyEvent = {'keyIdentifier': key}; | 137 var keyEvent = {'keyIdentifier': key}; |
| 138 // A keypress event is automatically generated for printable characters | 138 // A keypress event is automatically generated for printable characters |
| 139 // immediately following the keydown event. | 139 // immediately following the keydown event. |
| 140 if (chrome.experimental) { | 140 if (chrome.experimental) { |
| 141 keyEvent.type = 'keydown'; | 141 keyEvent.type = 'keydown'; |
| 142 chrome.experimental.input.sendKeyboardEvent(keyEvent); | 142 chrome.experimental.input.virtualKeyboard.sendKeyboardEvent(keyEvent); |
| 143 keyEvent.type = 'keyup'; | 143 keyEvent.type = 'keyup'; |
| 144 chrome.experimental.input.sendKeyboardEvent(keyEvent); | 144 chrome.experimental.input.virtualKeyboard.sendKeyboardEvent(keyEvent); |
| 145 } | 145 } |
| 146 // Exit shift mode after pressing any key but space. | 146 // Exit shift mode after pressing any key but space. |
| 147 if (currentMode == SHIFT_MODE && key != 'Spacebar') { | 147 if (currentMode == SHIFT_MODE && key != 'Spacebar') { |
| 148 transitionMode(SHIFT_MODE); | 148 transitionMode(SHIFT_MODE); |
| 149 } | 149 } |
| 150 // Enter shift mode after typing a closing punctuation and then a space for a | 150 // Enter shift mode after typing a closing punctuation and then a space for a |
| 151 // new sentence. | 151 // new sentence. |
| 152 if (enterShiftModeOnSpace) { | 152 if (enterShiftModeOnSpace) { |
| 153 enterShiftModeOnSpace = false; | 153 enterShiftModeOnSpace = false; |
| 154 if (currentMode != SHIFT_MODE && key == 'Spacebar') { | 154 if (currentMode != SHIFT_MODE && key == 'Spacebar') { |
| (...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 | 888 |
| 889 /** @inheritDoc */ | 889 /** @inheritDoc */ |
| 890 makeDOM: function(mode) { | 890 makeDOM: function(mode) { |
| 891 this.modeElements_[mode] = document.createElement('div'); | 891 this.modeElements_[mode] = document.createElement('div'); |
| 892 this.modeElements_[mode].className = 'key hide'; | 892 this.modeElements_[mode].className = 'key hide'; |
| 893 addContent(this.modeElements_[mode]); | 893 addContent(this.modeElements_[mode]); |
| 894 | 894 |
| 895 setupKeyEventHandlers(this, this.modeElements_[mode], | 895 setupKeyEventHandlers(this, this.modeElements_[mode], |
| 896 { 'down': function() { | 896 { 'down': function() { |
| 897 if (chrome.experimental) { | 897 if (chrome.experimental) { |
| 898 chrome.experimental.input.hideKeyboard(); | 898 chrome.experimental.input.virtualKeyboard.hideKeyboard(); |
| 899 } | 899 } |
| 900 }}); | 900 }}); |
| 901 | 901 |
| 902 return this.modeElements_[mode]; | 902 return this.modeElements_[mode]; |
| 903 } | 903 } |
| 904 }; | 904 }; |
| 905 | 905 |
| 906 /** | 906 /** |
| 907 * A container for keys. | 907 * A container for keys. |
| 908 * @param {number} position The position of the row (0-3). | 908 * @param {number} position The position of the row (0-3). |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 }, | 963 }, |
| 964 | 964 |
| 965 /** | 965 /** |
| 966 * Returns the size of keys this row contains. | 966 * Returns the size of keys this row contains. |
| 967 * @return {number} The size of keys. | 967 * @return {number} The size of keys. |
| 968 */ | 968 */ |
| 969 get length() { | 969 get length() { |
| 970 return this.keys_.length; | 970 return this.keys_.length; |
| 971 } | 971 } |
| 972 }; | 972 }; |
| OLD | NEW |