fix Ctrl+right/left handling in RTL fields

This commit is contained in:
ANH 2020-08-11 03:09:03 +03:00
parent d079307536
commit 46573df890

View File

@ -59,6 +59,29 @@ function onKey(evt: KeyboardEvent) {
focusPrevious();
return;
}
// fix Ctrl+right/left handling in RTL fields
if (currentField.dir === "rtl") {
const selection = window.getSelection();
let granularity = "character";
let alter = "move";
if (evt.ctrlKey) {
granularity = "word";
}
if (evt.shiftKey) {
alter = "extend";
}
if (evt.which === 39) {
selection.modify(alter, "right", granularity);
evt.preventDefault();
return;
} else if (evt.which === 37) {
selection.modify(alter, "left", granularity);
evt.preventDefault();
return;
}
}
triggerKeyTimer();
}