Anki/qt/aqt/data/web/js/webview.ts
Damien Elmes b2049209ff Re-enable formatting for .ts files
There are some style differences compared to prettier, and not all are
necessarily an improvement, but it's much faster now.
2022-11-28 09:33:04 +10:00

20 lines
617 B
TypeScript

/* Copyright: Ankitects Pty Ltd and contributors
* License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html */
// prevent backspace key from going back a page
document.addEventListener("keydown", function(evt: KeyboardEvent) {
if (evt.keyCode !== 8) {
return;
}
let isText = 0;
const node = evt.target as Element;
const nn = node.nodeName;
if (nn === "INPUT" || nn === "TEXTAREA") {
isText = 1;
} else if (nn === "DIV" && (node as HTMLDivElement).contentEditable) {
isText = 1;
}
if (!isText) {
evt.preventDefault();
}
});