ignore certain key codes
This commit is contained in:
parent
eff0185e44
commit
02a41530f4
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user