keydown_util: Ignore alt-arrow and similar things.

We ignore keystrokes like alt-left-arrow and alt-right-arrow,
so that the browser can do back/forward.

We may need to refine the handling of ctrl/alt/shift in the
future, but now we only support single-key operations.
This commit is contained in:
Steve Howell
2018-12-04 18:15:31 +00:00
committed by Tim Abbott
parent 7a2527aed1
commit a9391e0499
2 changed files with 21 additions and 6 deletions

View File

@@ -3,24 +3,35 @@ set_global('$', global.make_zjquery());
zrequire('keydown_util');
run_test('test_early_returns', () => {
var stub = $.create('stub');
var opts = {
const stub = $.create('stub');
const opts = {
elem: stub,
handlers: {},
handlers: {
left_arrow: () => {
throw Error('do not dispatch this with alt key');
},
},
};
keydown_util.handle(opts);
var keydown_f = stub.keydown;
const keydown_f = stub.keydown;
var e1 = {
const e1 = {
which: 17, // not in keys
};
keydown_f(e1);
var e2 = {
const e2 = {
which: 13, // no handler
};
keydown_f(e2);
const e3 = {
which: 37,
altKey: true, // let browser handle
};
keydown_f(e3);
});