Closed iongion closed 8 years ago
I have a strange device - ShuttleXpress that by default sends some weird key combinations that must be hijacked to prevent default behavior(zooming the browser content).
For small wheel rotation to the right I see the following sequence of events:
// appear altogether when motion starts
{keyCode: 144, location: 0, ctrlKey: false, altKey: false, shiftKey: false…}
{keyCode: 17, location: 1, ctrlKey: true, altKey: false, shiftKey: false…}
{keyCode: 187, location: 0, ctrlKey: true, altKey: false, shiftKey: false…}
// small pause, it appears after the first 3 logs above and when motion stops
{keyCode: 144, location: 0, ctrlKey: false, altKey: false, shiftKey: false…}
I looked inside the source code of keypress to see what these codes map to:
144
=> num17
=> ctrl, but the location is 1 so left ctrl187
=> =, but this one has the ctrl key set to true144
=> numNow I do not really understand how to read it, it could be:
num + [ctrl + = ]
Add this to my code:
this.listener.register_combo({
keys: 'num ctrl =',
prevent_default: true,
on_keydown: () => {
console.debug('decrease val');
},
});
I see the default behavior is prevented(no more zoom ocurring) but as mentioned before, on_keydown
does not get invoked.
Investigated even more and apparently this is the key combo:
start rotation
144 - down
144 - up
17 - down
187 - down
187 - up
17 - up
stop rotation
144 - down
144 - up
How can this be mapped to Keypress.js ?
If your browser is sending keypress events, I don't think that we can guarantee that they will happen in any sort of sane manner. On keydown not getting called is probably a result of the weird behavior. Try on keyup or on keypress, but probably it's just not compatible.
For the combos bellow:
Although the behavior is correct and it actual hooks on the right keys, the events callbacks are not invoked, none of the
on_keydown, on_keyup, on_release
What can be done to overcome this ?