Skip to content

Commit

Permalink
Merge pull request #1849 from epicfaace/feature/hold-key
Browse files Browse the repository at this point in the history
Allow holding key on mac to send multiple keys to terminal
  • Loading branch information
Tyriar authored Dec 27, 2018
2 parents b48f910 + 9bcfb4d commit 838d727
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/core/input/Keyboard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,5 +281,16 @@ describe('Keyboard', () => {
assert.equal(testEvaluateKeyboardEvent({ keyCode: 0, key: 'UIKeyInputDownArrow' }).key, '\x1b[B');
assert.equal(testEvaluateKeyboardEvent({ keyCode: 0, key: 'UIKeyInputDownArrow' }, { applicationCursorMode: true }).key, '\x1bOB');
});

it('should handle lowercase letters', () => {
assert.equal(testEvaluateKeyboardEvent({ keyCode: 65, key: 'a' }).key, 'a');
assert.equal(testEvaluateKeyboardEvent({ keyCode: 189, key: '-' }).key, '-');
});

it('should handle uppercase letters', () => {
assert.equal(testEvaluateKeyboardEvent({ shiftKey: true, keyCode: 65, key: 'A' }).key, 'A');
assert.equal(testEvaluateKeyboardEvent({ shiftKey: true, keyCode: 49, key: '!' }).key, '!');
});

});
});
4 changes: 4 additions & 0 deletions src/core/input/Keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,10 @@ export function evaluateKeyboardEvent(
if (ev.keyCode === 65) { // cmd + a
result.type = KeyboardResultType.SELECT_ALL;
}
} else if (ev.key && !ev.ctrlKey && !ev.altKey && !ev.metaKey &&
ev.keyCode >= 48 && ev.keyCode !== 144 && ev.keyCode !== 145) {
// Include only keys that that result in a character; don't include num lock and scroll lock
result.key = ev.key;
}
break;
}
Expand Down

0 comments on commit 838d727

Please sign in to comment.