Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't handle keyup that is handled by custom handler #2294

Merged
merged 2 commits into from
Jul 8, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 9 additions & 23 deletions src/Terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -512,29 +512,7 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
* Apply key handling to the terminal
*/
private _bindKeys(): void {
const self = this;
this.register(addDisposableDomListener(this.element, 'keydown', function (ev: KeyboardEvent): void {
if (document.activeElement !== this) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will always return so we can safety remove this.

return;
}
self._keyDown(ev);
}, true));

this.register(addDisposableDomListener(this.element, 'keypress', function (ev: KeyboardEvent): void {
if (document.activeElement !== this) {
return;
}
self._keyPress(ev);
}, true));

this.register(addDisposableDomListener(this.element, 'keyup', (ev: KeyboardEvent) => {
if (!wasModifierKeyOnlyEvent(ev)) {
this.focus();
}

self._keyUp(ev);
}, true));

this.register(addDisposableDomListener(this.textarea, 'keyup', (ev: KeyboardEvent) => this._keyUp(ev), true));
this.register(addDisposableDomListener(this.textarea, 'keydown', (ev: KeyboardEvent) => this._keyDown(ev), true));
this.register(addDisposableDomListener(this.textarea, 'keypress', (ev: KeyboardEvent) => this._keyPress(ev), true));
this.register(addDisposableDomListener(this.textarea, 'compositionstart', () => this._compositionHelper.compositionstart()));
Expand Down Expand Up @@ -1628,6 +1606,14 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
}

protected _keyUp(ev: KeyboardEvent): void {
if (this._customKeyEventHandler && this._customKeyEventHandler(ev) === false) {
return;
}

if (!wasModifierKeyOnlyEvent(ev)) {
this.focus();
}

this.updateCursorStyle(ev);
}

Expand Down