ignore certain key codes
This commit is contained in:
parent
eff0185e44
commit
02a41530f4
@ -22,13 +22,20 @@
|
|||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
|
|
||||||
// save after half-second delay after typing
|
|
||||||
var timer = null;
|
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);
|
clearTimeout(timer);
|
||||||
timer = setTimeout(function () {
|
|
||||||
saveContent();
|
// only set timer if key isn't ignored
|
||||||
}, 1000);
|
if (!ignoredKeyCodes.includes(e.keyCode)) {
|
||||||
|
timer = setTimeout(function () {
|
||||||
|
saveContent();
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 20 second interval
|
// 20 second interval
|
||||||
|
Loading…
x
Reference in New Issue
Block a user