Skip to content

Commit 94fce87

Browse files
committed
Potential Ctrl compatability
Not 100% on if this is really needed or not.
1 parent 06f604d commit 94fce87

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

packages/keyboard/src/core.ts

+12
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ export class KeycodeLayout implements IKeyboardLayout {
124124
* @returns `true` if the key is valid, `false` otherwise.
125125
*/
126126
isValidKey(key: string): boolean {
127+
key = Private.normalizeCtrl(key);
127128
return key in this._keys || Private.isSpecialCharacter(key);
128129
}
129130

@@ -135,6 +136,7 @@ export class KeycodeLayout implements IKeyboardLayout {
135136
* @returns `true` if the key is a modifier key, `false` otherwise.
136137
*/
137138
isModifierKey(key: string): boolean {
139+
key = Private.normalizeCtrl(key);
138140
return key in this._modifierKeys;
139141
}
140142

@@ -236,4 +238,14 @@ namespace Private {
236238
// or more alphanumeric basic latin characters, it is likely a special key.
237239
return SPECIAL_KEYS.has(key);
238240
}
241+
242+
/**
243+
* Normalize Ctrl to Control for backwards compatability.
244+
*
245+
* @param key - The key value that is to be normalized
246+
* @returns The normalized key string
247+
*/
248+
export function normalizeCtrl(key: string): string {
249+
return key === "Ctrl" ? "Control" : key;
250+
}
239251
}

0 commit comments

Comments
 (0)