2019-02-05 04:59:03 +01:00
|
|
|
/* Copyright: Ankitects Pty Ltd and contributors
|
|
|
|
* License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html */
|
|
|
|
|
2017-08-01 09:04:55 +02:00
|
|
|
// prevent backspace key from going back a page
|
2020-06-24 13:54:38 +02:00
|
|
|
document.addEventListener("keydown", function (evt: KeyboardEvent) {
|
2017-08-01 09:04:55 +02:00
|
|
|
if (evt.keyCode !== 8) {
|
|
|
|
return;
|
|
|
|
}
|
2019-12-18 04:02:11 +01:00
|
|
|
let isText = 0;
|
|
|
|
const node = evt.target as Element;
|
|
|
|
const nn = node.nodeName;
|
2017-08-01 09:04:55 +02:00
|
|
|
if (nn === "INPUT" || nn === "TEXTAREA") {
|
|
|
|
isText = 1;
|
2019-12-18 04:02:11 +01:00
|
|
|
} else if (nn === "DIV" && (node as HTMLDivElement).contentEditable) {
|
2017-08-01 09:04:55 +02:00
|
|
|
isText = 1;
|
|
|
|
}
|
|
|
|
if (!isText) {
|
|
|
|
evt.preventDefault();
|
|
|
|
}
|
|
|
|
});
|