Index: chrome/browser/resources/chromeos/braille_ime/braille_ime.js |
diff --git a/chrome/browser/resources/chromeos/braille_ime/braille_ime.js b/chrome/browser/resources/chromeos/braille_ime/braille_ime.js |
index 885f6df877094a8b1a0bdbf93167a666074b1109..5ea42d2274d7392e6215f930c30b8fb39ac7e0b7 100644 |
--- a/chrome/browser/resources/chromeos/braille_ime/braille_ime.js |
+++ b/chrome/browser/resources/chromeos/braille_ime/braille_ime.js |
@@ -93,11 +93,12 @@ BrailleIme.prototype = { |
* Note that the mapping below is arranged like the dots in a braille cell. |
* Only 6 dot input is supported. |
* @private |
- * @const {Object.<string, string>} |
+ * @const {Object.<string, number>} |
*/ |
CODE_TO_DOT_: {'KeyF': 0x01, 'KeyJ': 0x08, |
'KeyD': 0x02, 'KeyK': 0x10, |
- 'KeyS': 0x04, 'KeyL': 0x20 }, |
+ 'KeyS': 0x04, 'KeyL': 0x20 , |
David Tseng
2014/05/07 18:05:54
nit: extra space before comma
|
+ 'Space': 0}, |
David Tseng
2014/05/07 18:05:54
nit: space before }
|
/** |
* The current engine ID as set by {@code onActivate}, or the empty string if |
@@ -201,7 +202,7 @@ BrailleIme.prototype = { |
*/ |
onKeyEvent_: function(engineID, event) { |
this.log_('onKeyEvent', engineID + ', ' + JSON.stringify(event)); |
- return this.processKey_(event.code, event.type); |
+ return this.processKey_(event); |
}, |
/** |
@@ -253,28 +254,33 @@ BrailleIme.prototype = { |
/** |
* Handles a querty key on the home row as a braille key. |
David Tseng
2014/05/07 18:05:54
nit: I think it's "qwerty"
|
- * @param {string} code Key code. |
- * @param {string} type Type of key event. |
+ * @param {!ChromeKeyboardEvent} event Keyboard event. |
* @return {boolean} Whether the key event was handled or not. |
* @private |
*/ |
- processKey_: function(code, type) { |
+ processKey_: function(event) { |
if (!this.useStandardKeyboard_) { |
return false; |
} |
- var dot = this.CODE_TO_DOT_[code]; |
- if (!dot) { |
+ var dot = this.CODE_TO_DOT_[event.code]; |
+ if (dot === undefined || event.altKey || event.ctrlKey || event.shiftKey || |
+ event.capsLock) { |
this.pressed_ = 0; |
this.accumulated_ = 0; |
return false; |
} |
- if (type === 'keydown') { |
- this.pressed_ |= dot; |
- this.accumulated_ |= this.pressed_; |
+ if (event.type === 'keydown') { |
+ if (dot !== 0) { |
+ this.pressed_ |= dot; |
+ this.accumulated_ |= this.pressed_; |
+ } else { |
+ // Space cancels other dots. |
David Tseng
2014/05/07 18:05:54
Just wondering about the behavior here. If I hold
|
+ this.pressed_ = this.accumulated_ = 0; |
+ } |
return true; |
- } else if (type == 'keyup') { |
+ } else if (event.type === 'keyup') { |
this.pressed_ &= ~dot; |
- if (this.pressed_ == 0 && this.accumulated_ != 0) { |
+ if (this.pressed_ === 0 && (this.accumulated_ !== 0 || dot === 0)) { |
this.sendToChromeVox_({type: 'brailleDots', dots: this.accumulated_}); |
this.accumulated_ = 0; |
} |