issue #20689: hack through key capture bugs
authorSteve Hackbarth <stephenhackbarth@gmail.com>
Mon, 16 Dec 2013 19:51:47 +0000 (14:51 -0500)
committerSteve Hackbarth <stephenhackbarth@gmail.com>
Mon, 16 Dec 2013 19:51:47 +0000 (14:51 -0500)
lib/enyo-x/source/app.js

index c42d466..b2df12d 100644 (file)
@@ -44,27 +44,32 @@ white:true*/
       pattern-match mode
     */
     handleKeyDown: function (inSender, inEvent) {
-      var that = this;
+      var that = this,
+        keyCode = inEvent.keyCode;
 
       // remember the last 10 key presses
-      this._keyBufferArray.push(inEvent.keyCode);
+      this._keyBufferArray.push(keyCode);
       this._keyBufferArray = this._keyBufferArray.slice(-10);
 
       // not working
       if (this.$.postbooks.isNotifyPopupShowing()) {
-        this.$.postbooks.notifyKey(inEvent.keyCode, inEvent.shiftKey);
+        this.$.postbooks.notifyKey(keyCode, inEvent.shiftKey);
         return;
       }
 
+      if (keyCode === 189) {
+        // XXX FIXME hack. Dashes aren't coming through as dashes from my keyboard
+        keyCode = '-'.charCodeAt(0);
+      }
       if (inEvent.altKey) {
         inEvent.cancelBubble = true;
         inEvent.returnValue = false;
-        this.processHotKey(inEvent.keyCode);
+        this.processHotKey(keyCode);
         return true;
       }
       if (this._keyBufferEndPattern) {
         // we're in record mode, so record.
-        this._keyBuffer = this._keyBuffer + String.fromCharCode(inEvent.keyCode);
+        this._keyBuffer = this._keyBuffer + String.fromCharCode(keyCode);
       }
 
       if (this._keyBufferEndPattern &&
@@ -74,6 +79,10 @@ white:true*/
 
       } else if (this._keyBufferEndPattern &&
           _.isEqual(this._keyBufferArray.slice(-1 * this._keyBufferEndPattern.length), this._keyBufferEndPattern)) {
+
+        // first slice the end pattern off the payload
+        this._keyBuffer = this._keyBuffer.substring(0, this._keyBuffer.length - this._keyBufferEndPattern.length);
+
         // we've matched an end pattern. Send the recorded buffer to the appropriate method
         this[this._keyBufferMethod](this._keyBuffer);
         this._keyBuffer = "";