add api.feature.on_key override

This commit is contained in:
Stewart Allen 2020-04-12 14:35:24 -04:00
commit d44630251f

View file

@ -135,6 +135,9 @@ var gs_kiri_init = exports;
}
function keyUpHandler(evt) {
if (API.feature.on_key) {
if (API.feature.on_key({up:evt})) return;
}
switch (evt.keyCode) {
// escape
case 27:
@ -161,6 +164,9 @@ var gs_kiri_init = exports;
if (API.modal.visible()) {
return false;
}
if (API.feature.on_key) {
if (API.feature.on_key({down:evt})) return;
}
let move = evt.altKey ? 5 : 0,
deg = move ? 0 : -Math.PI / (evt.shiftKey ? 36 : 2);
switch (evt.keyCode) {
@ -232,6 +238,9 @@ var gs_kiri_init = exports;
if (API.modal.visible() || inputHasFocus()) {
return false;
}
if (API.feature.on_key) {
if (API.feature.on_key({key:evt})) return;
}
switch (evt.charCode) {
case cca('`'): API.show.slices(0); break;
case cca('0'): API.show.slices(API.var.layer_max); break;
@ -1051,6 +1060,7 @@ var gs_kiri_init = exports;
});
SPACE.platform.onMove(API.conf.save);
SPACE.platform.setRound(true);
SPACE.useDefaultKeys(API.feature.on_key === undefined);
UC.setCompact(compact);