2020-07-15 01:29:15 +02:00
|
|
|
set_global("$", global.make_zjquery());
|
2018-07-23 00:45:46 +02:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
zrequire("keydown_util");
|
2018-07-23 00:45:46 +02:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
run_test("test_early_returns", () => {
|
|
|
|
const stub = $.create("stub");
|
2018-12-04 19:15:31 +01:00
|
|
|
const opts = {
|
2018-07-23 00:45:46 +02:00
|
|
|
elem: stub,
|
2018-12-04 19:15:31 +01:00
|
|
|
handlers: {
|
|
|
|
left_arrow: () => {
|
2020-07-15 01:29:15 +02:00
|
|
|
throw Error("do not dispatch this with alt key");
|
2018-12-04 19:15:31 +01:00
|
|
|
},
|
|
|
|
},
|
2018-07-23 00:45:46 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
keydown_util.handle(opts);
|
2018-12-04 19:15:31 +01:00
|
|
|
const keydown_f = stub.keydown;
|
2018-07-23 00:45:46 +02:00
|
|
|
|
2018-12-04 19:15:31 +01:00
|
|
|
const e1 = {
|
2018-07-23 00:45:46 +02:00
|
|
|
which: 17, // not in keys
|
|
|
|
};
|
|
|
|
|
|
|
|
keydown_f(e1);
|
|
|
|
|
2018-12-04 19:15:31 +01:00
|
|
|
const e2 = {
|
2018-07-23 00:45:46 +02:00
|
|
|
which: 13, // no handler
|
|
|
|
};
|
|
|
|
|
|
|
|
keydown_f(e2);
|
2018-12-04 19:15:31 +01:00
|
|
|
|
|
|
|
const e3 = {
|
|
|
|
which: 37,
|
|
|
|
altKey: true, // let browser handle
|
|
|
|
};
|
|
|
|
|
|
|
|
keydown_f(e3);
|
2018-07-23 00:45:46 +02:00
|
|
|
});
|