From 7f74e4ba53d33fd00a5f3eb136e4f4a3eafe7c2a Mon Sep 17 00:00:00 2001 From: Just van Rossum Date: Wed, 4 Dec 2024 16:06:32 +0100 Subject: [PATCH 1/2] Fix 'clean view' on Safari, by improving the navigator.keyboard fallback logic --- src/fontra/client/core/actions.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/fontra/client/core/actions.js b/src/fontra/client/core/actions.js index a0648128fb..990404b897 100644 --- a/src/fontra/client/core/actions.js +++ b/src/fontra/client/core/actions.js @@ -236,6 +236,10 @@ function fetchKeyboardLayout() { fetchKeyboardLayout(); +const legacyMapping = { + " ": "Space", +}; + export function getBaseKeyFromKeyEvent(event) { assert(event.type === "keydown" || event.type === "keyup"); @@ -256,6 +260,8 @@ export function getBaseKeyFromKeyEvent(event) { event.keyCode <= 126 ? String.fromCodePoint(event.keyCode).toLowerCase() : event.key; + + baseKey = legacyMapping[baseKey] || baseKey; } return baseKey || event.code; From d558d08c6315e0cf09430f23bf85bdcb8cb9ef0e Mon Sep 17 00:00:00 2001 From: Just van Rossum Date: Wed, 4 Dec 2024 16:08:03 +0100 Subject: [PATCH 2/2] Improve variable name --- src/fontra/client/core/actions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fontra/client/core/actions.js b/src/fontra/client/core/actions.js index 990404b897..8828bcb012 100644 --- a/src/fontra/client/core/actions.js +++ b/src/fontra/client/core/actions.js @@ -236,7 +236,7 @@ function fetchKeyboardLayout() { fetchKeyboardLayout(); -const legacyMapping = { +const keyboardFallbackMapping = { " ": "Space", }; @@ -261,7 +261,7 @@ export function getBaseKeyFromKeyEvent(event) { ? String.fromCodePoint(event.keyCode).toLowerCase() : event.key; - baseKey = legacyMapping[baseKey] || baseKey; + baseKey = keyboardFallbackMapping[baseKey] || baseKey; } return baseKey || event.code;