Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit 924409a

Browse files
maxbrunsfeldNathan Sobo
authored andcommitted
Use KeyboardEvent.key property as much as possible
The only time that we can't use KeyboardEvent.key is on macOS when the option key is held down. In that case, the .key property will contain an alternative character. In order to match alt bindings, we need to know the character that the key would have typed if option were not held down. We determine this character using the keyboard-layout module. Signed-off-by: Nathan Sobo <nathan@github.com>
1 parent 4df69d1 commit 924409a

File tree

8 files changed

+574
-1064
lines changed

8 files changed

+574
-1064
lines changed

spec/helpers/helpers.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
import lolex from 'lolex'
66
import sinon from 'sinon'
77

8-
let sinonSandbox, fakeClock
8+
let sinonSandbox, fakeClock, processPlatform, originalProcessPlatform
9+
10+
originalProcessPlatform = process.platform
11+
processPlatform = process.platform
12+
Object.defineProperty(process, 'platform', {get: () => processPlatform})
913

1014
beforeEach(function () {
1115
document.body.innerHTML = ''
@@ -16,6 +20,7 @@ beforeEach(function () {
1620
afterEach(function () {
1721
fakeClock.uninstall()
1822
sinonSandbox.restore()
23+
processPlatform = originalProcessPlatform
1924
})
2025

2126
export function appendContent (element) {
@@ -30,3 +35,7 @@ export function stub () {
3035
export function getFakeClock () {
3136
return fakeClock
3237
}
38+
39+
export function mockProcessPlatform (platform) {
40+
processPlatform = platform
41+
}

0 commit comments

Comments
 (0)