| 1495 | // Suppress all keyboard events until the user stops typing for sufficiently long. |
| 1496 | class TypingProtector extends Mode { |
| 1497 | constructor(delay, callback) { |
| 1498 | super(); |
| 1499 | this.init({ |
| 1500 | name: "hint/typing-protector", |
| 1501 | suppressAllKeyboardEvents: true, |
| 1502 | keydown: resetExitTimer, |
| 1503 | keypress: resetExitTimer, |
| 1504 | }); |
| 1505 | |
| 1506 | this.timer = Utils.setTimeout(delay, () => this.exit()); |
| 1507 | |
| 1508 | const resetExitTimer = () => { |
| 1509 | clearTimeout(this.timer); |
| 1510 | this.timer = Utils.setTimeout(delay, () => this.exit()); |
| 1511 | }; |
| 1512 | |
| 1513 | this.onExit(() => callback(true)); // true -> isSuccess. |
| 1514 | } |
| 1515 | } |
| 1516 | |
| 1517 | class WaitForEnter extends Mode { |