From 2f8d49c74df812e8c4a5a90b0f5b44c5d3dcb2d9 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Thu, 4 Apr 2019 00:45:57 -0400 Subject: [PATCH] Convert internal key event usages --- src/AccessibilityManager.ts | 2 +- src/Terminal.ts | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/AccessibilityManager.ts b/src/AccessibilityManager.ts index 877676c9..a8e0ba1b 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 f6a987f7..5d2e96de 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);