Key down event handler if this object is being edited * @param {KeyboardEvent} [e]
(e)
| 1108 | /** Key down event handler if this object is being edited |
| 1109 | * @param {KeyboardEvent} [e] */ |
| 1110 | onKeyDown(e) |
| 1111 | { |
| 1112 | const code = e.code, key = e.key |
| 1113 | if (code === 'Backspace') |
| 1114 | this.text = this.text.slice(0, -1); |
| 1115 | else if (code === 'Enter' || code === 'Escape') |
| 1116 | this.stopEditing(); |
| 1117 | else if (key.length === 1) // printable characters |
| 1118 | { |
| 1119 | if (!this.maxLength || this.text.length < this.maxLength) |
| 1120 | this.text += key; |
| 1121 | } |
| 1122 | } |
| 1123 | |
| 1124 | update() |
| 1125 | { |
no test coverage detected