Skip to content

Commit

Permalink
Merge pull request #1835 from googlefonts/fix-space-key-safari
Browse files Browse the repository at this point in the history
Fix 'clean view' on Safari, by improving the navigator.keyboard fallback logic
  • Loading branch information
justvanrossum authored Dec 4, 2024
2 parents 1b74da5 + d558d08 commit 9bce849
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/fontra/client/core/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ function fetchKeyboardLayout() {

fetchKeyboardLayout();

const keyboardFallbackMapping = {
" ": "Space",
};

export function getBaseKeyFromKeyEvent(event) {
assert(event.type === "keydown" || event.type === "keyup");

Expand All @@ -256,6 +260,8 @@ export function getBaseKeyFromKeyEvent(event) {
event.keyCode <= 126
? String.fromCodePoint(event.keyCode).toLowerCase()
: event.key;

baseKey = keyboardFallbackMapping[baseKey] || baseKey;
}

return baseKey || event.code;
Expand Down

0 comments on commit 9bce849

Please sign in to comment.