Keypress icon indicating copy to clipboard operation
Keypress copied to clipboard

bug: registration of keys failed

Open Hallasdor opened this issue 10 years ago • 2 comments

Button keep being in 'pressed' state after surtain combinations. This happens if you perform the following actions: 1] press and hold shift button 2] press and hold any of the 'num0', 'num1', 'num2', 'num3', 'num4', 'num5', 'num6', 'num7', 'num8', 'num9', 'num.' buttons 3] release the shift button 4] release the button pressed in [2]

The reason for this seems to be that these numpad buttons have a completely different button registration when pressing the shift button. As soon as you release the shift button, the release function registrates a different button for the release state.

This bug can be repeated everytime if you follow the 4 steps.

It is probably impossible to register the correct buttons (I'm assuming the browser registers the 'wrong' button), so maybe you should (also) register the numpad buttons in these specific scenario's

Hallasdor avatar Apr 08 '15 11:04 Hallasdor

I have created a (dirty) fix for this problem. Hopefully this will help others in the future.

Listener.prototype._key_down = function (key, e) { // line 451

function checkForCounterpart(key, list) {
    if (list.length > 0) {
        var index = list.indexOf(key);
        if (index > -1) {
            list.splice(index, 1);
        }
    }
};

switch (key) {
    case "num_decimal":
        checkForCounterpart("delete", this._keys_down);
        break;
    case "num_0":
        checkForCounterpart("insert", this._keys_down);
        break;
    case "num_1":
        checkForCounterpart("end", this._keys_down);
        break;
    case "num_2":
        checkForCounterpart("down", this._keys_down);
        break;
    case "num_3":
        checkForCounterpart("pagedown", this._keys_down);
        break;
    case "num_4":
        checkForCounterpart("left", this._keys_down);
        break;
    case "num_5":
        checkForCounterpart("num", this._keys_down);
        break;
    case "num_6":
        checkForCounterpart("right", this._keys_down);
        break;
    case "num_7":
        checkForCounterpart("home", this._keys_down);
        break;
    case "num_8":
        checkForCounterpart("up", this._keys_down);
        break;
    case "num_9":
        checkForCounterpart("pageup", this._keys_down);
        break;
}
... //the original code

}

Hallasdor avatar Apr 08 '15 14:04 Hallasdor

What browser/OS combo are you seeing this with? Are any other supported keys doing this? I can't reproduce it on OS X + Chrome.

dmauro avatar Aug 16 '15 17:08 dmauro