sharad-github / shellinabox

Automatically exported from code.google.com/p/shellinabox
Other
0 stars 0 forks source link

keyUp is generating duplicate (shifted) keypresses on Firefox and Chrome on Mac #258

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
  1. login to bash (or any other service) with shellinabox
  2. press any alphabetic key, and keep it pressed for a second or two
  3. release the key

What is the expected output? What do you see instead?

  Expect the pressed key to be input (and echoed), If you've kept it pressed long enough, expect the pressed key to repeat (until you release it). 

  What actually happens is that the key is input correctly when you press the key down. It doesn't repeat. But when you release the key, the character is input a second time. If you'd typed a lower-case character, the repeated character is inserted as its upper-case equivalent (though there is no SHIFT key pressed). 

What version of the product are you using? On what operating system?

  version 2.14, on Mac OSX 10.9.2 Mavericks.

Please provide any additional information below.

  Only a problem with Chrome and Firefox. It works as expected (no keyUp event fired) on Safari.

I worked around the problem by putting in a hacky patch:

--- vt100.js.orig   2014-04-04 17:18:02.000000000 +0100
+++ vt100.js    2014-04-04 17:30:28.000000000 +0100
@@ -3102,6 +3102,7 @@
       fake.metaKey                = event.metaKey;
       if (asciiKey) {
         fake.charCode             = event.keyCode;
+        if (!event.shiftKey) fake.charCode |= 040; /*  if it's not shifted, 
lower-case it */
         fake.keyCode              = 0;
       } else {
         fake.charCode             = 0;
@@ -3110,8 +3111,10 @@
           fake                    = this.fixEvent(fake);
         }
       }
-      this.lastNormalKeyDownEvent = undefined;
-      this.handleKey(fake);
+      if (!asciiKey || fake.charCode != lastNormalKeyDownEvent.keyCode) {
+        this.lastNormalKeyDownEvent = undefined;
+        this.handleKey(fake);
+      }
     }
   }

Original issue reported on code.google.com by Simon.Br...@gmail.com on 4 Apr 2014 at 4:45