diff --git a/src/AccessibilityManager.ts b/src/AccessibilityManager.ts index 877676c97..a8e0ba1bc 100644 --- a/src/AccessibilityManager.ts +++ b/src/AccessibilityManager.ts @@ -79,7 +79,7 @@ export class AccessibilityManager extends Disposable { this.register(this._terminal.addDisposableListener('a11y.char', (char) => this._onChar(char))); this.register(this._terminal.addDisposableListener('linefeed', () => this._onChar('\n'))); this.register(this._terminal.addDisposableListener('a11y.tab', spaceCount => this._onTab(spaceCount))); - this.register(this._terminal.addDisposableListener('key', keyChar => this._onKey(keyChar))); + this.register(this._terminal.onKey(e => this._onKey(e.key))); this.register(this._terminal.addDisposableListener('blur', () => this._clearLiveRegion())); // TODO: Maybe renderer should fire an event on terminal when the characters change and that // should be listened to instead? That would mean that the order of events are always diff --git a/src/Terminal.ts b/src/Terminal.ts index f6a987f7f..5d2e96ded 100644 --- a/src/Terminal.ts +++ b/src/Terminal.ts @@ -266,9 +266,12 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II this.on('data', e => this._onInput.fire(e)); this.on('title', e => this._onTitleChange.fire(e)); this.on('scroll', e => this._onScroll.fire(e)); - this.on('key', e => this._onKey.fire(e)); this.on('refresh', e => this._onRender.fire(e)); this.on('resize', e => this._onResize.fire(e)); + + // TODO: Remove these in v4 + // Fire old style events from new emitters + this.onKey(e => this.emit('key', e.key, e.domEvent)); } public dispose(): void { @@ -1615,7 +1618,7 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II } this.emit('keydown', event); - this.emit('key', result.key, event); + this._onKey.fire({ key: result.key, domEvent: event }); this.showCursor(); this.handler(result.key); @@ -1694,7 +1697,7 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II key = String.fromCharCode(key); this.emit('keypress', key, ev); - this.emit('key', key, ev); + this._onKey.fire({ key, domEvent: ev }); this.showCursor(); this.handler(key);