Skip to content

Commit

Permalink
triggerKeyEvent now uses find instead of filter[0]
Browse files Browse the repository at this point in the history
  • Loading branch information
izelnakri committed Dec 6, 2020
1 parent c4cedbb commit 50358bf
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ function keyFromKeyCodeAndModifiers(keycode: number, modifiers: KeyModifiers): s
*/
function keyCodeFromKey(key: string) {
let keys = Object.keys(keyFromKeyCode);
let keyCode = keys.filter(keyCode => keyFromKeyCode[Number(keyCode)] === key)[0];
if (!keyCode) {
keyCode = keys.filter(keyCode => keyFromKeyCode[Number(keyCode)] === key.toLowerCase())[0];
}
let keyCode =
keys.find(keyCode => keyFromKeyCode[Number(keyCode)] === key) ||
keys.find(keyCode => keyFromKeyCode[Number(keyCode)] === key.toLowerCase());

return keyCode !== undefined ? parseInt(keyCode) : undefined;
}

Expand Down

0 comments on commit 50358bf

Please sign in to comment.