Skip to content

Commit

Permalink
Prevent loosing focus after a char composition ended by Tab key. Fix v…
Browse files Browse the repository at this point in the history
  • Loading branch information
chabou authored and rauchg committed Jan 7, 2017
1 parent 9bbcbea commit ffc8820
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/hterm.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,22 @@ hterm.Terminal.prototype.copySelectionToClipboard = function () {
}
};

let lastEventTimeStamp;
let lastEventKey;
// passthrough all the commands that are meant to control
// hyper and not the terminal itself
const oldKeyDown = hterm.Keyboard.prototype.onKeyDown_;
hterm.Keyboard.prototype.onKeyDown_ = function (e) {
const modifierKeysConf = this.terminal.modifierKeys;
if (e.timeStamp === lastEventTimeStamp && e.key === lastEventKey) {
// Event was already processed.
// It seems to occur after a char composition ended by Tab and cause a blur.
// See https://github.com/zeit/hyper/issues/1341
e.preventDefault();
return;
}
lastEventTimeStamp = e.timeStamp;
lastEventKey = e.key;

if (e.altKey &&
e.which !== 16 && // Ignore other modifer keys
Expand Down

0 comments on commit ffc8820

Please sign in to comment.