(options)
| 34 | } |
| 35 | |
| 36 | init(options) { |
| 37 | const args = Object.assign(options, { keydown: this.onKeydown.bind(this) }); |
| 38 | super.init(args); |
| 39 | |
| 40 | this.commandHandler = options.commandHandler || (function () {}); |
| 41 | this.setKeyMapping(options.keyMapping || {}); |
| 42 | |
| 43 | if (options.exitOnEscape) { |
| 44 | // If we're part way through a command's key sequence, then a first Escape should reset the |
| 45 | // key state, and only a second Escape should actually exit this mode. |
| 46 | this.push({ |
| 47 | _name: "key-handler-escape-listener", |
| 48 | keydown: (event) => { |
| 49 | if (KeyboardUtils.isEscape(event) && !this.isInResetState()) { |
| 50 | this.reset(); |
| 51 | return this.suppressEvent; |
| 52 | } else { |
| 53 | return this.continueBubbling; |
| 54 | } |
| 55 | }, |
| 56 | }); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | onKeydown(event) { |
| 61 | const keyChar = KeyboardUtils.getKeyCharString(event); |
nothing calls this directly
no test coverage detected