ignore certain key codes

This commit is contained in:
Ryan Peters 2022-12-02 15:18:04 -05:00
parent eff0185e44
commit 02a41530f4

View File

@ -22,13 +22,20 @@
$(function () {
// save after half-second delay after typing
var timer = null;
$('textarea').keyup(function () {
let ignoredKeyCodes = [17, 18, 20, 27, 37, 38, 39, 40, 91];
// save after half-second delay after typing
$('textarea').keyup(function (e) {
clearTimeout(timer);
timer = setTimeout(function () {
saveContent();
}, 1000);
// only set timer if key isn't ignored
if (!ignoredKeyCodes.includes(e.keyCode)) {
timer = setTimeout(function () {
saveContent();
}, 1000);
}
});
// 20 second interval