Keyboard layout changes to wrong layout during usage
See original GitHub issueDescription
Finnish keyboard layout: http://kbdlayout.info/KBDFI/
So initially the layout is all good. As you can see, I can type multiple “-” (next to right-shift) on my Finnish keyboard. But when I “submit” the answer the next time I’m using mathfield the layout has changed to a wrong layout, where pressing the same key leads it to be interpreted as “/” which leads to a fraction.
About that “submit”. Copy-pasting all my code to codesandbox would take a bit too much time I try to explain the part of code that I think is relevant to this issue. I could share @arnog my private repo for a moment to debug this if you think that’s needed.
const handleOnEnterKeyPressedOrFocusLostAndValueChanged = () => {
if (mfe.value !== "") {
// This is a long function (that comes from parent component) that get's called when I "submit" the answer
// Eg. Checking the answer, clearing states, showing the success message etc.
onEnterKeyPressedOrFocusLostAndValueChanged(mfe.getValue(format))
mfe.setValue("")
}
}
useLayoutEffect(() => {
console.log("Mounting mathfield")
ref.current?.appendChild(mfe)
mfe.addEventListener(
"change",
handleOnEnterKeyPressedOrFocusLostAndValueChanged
)
mfe.focus()
return () => {
console.log("Unmounting mathfield")
mfe.removeEventListener(
"change",
handleOnEnterKeyPressedOrFocusLostAndValueChanged
)
ref.current?.removeChild(mfe)
}
}, [])
Steps to Reproduce
- I start using mathfield and it’s working
- As long as I don’t press “-” everything works as intended
- When I at some point of time press “-”, the next math challenge I try to type “-” is interpreted as a fraction
Actual Behavior
I can’t type “-”
Expected Behavior
I can type “-”
Environment
MathLive version
0.69.7
Issue Analytics
- State:
- Created 2 years ago
- Comments:28 (12 by maintainers)
Top Results From Across the Web
Windows 10 keyboard layout change error
Click Start and type "troubleshoot" then select the first result. Scroll down and choose Keyboard. Run the troubleshooter and it might fix the ......
Read more >How to avoid keyboard layout automatically changing on ...
Go to Control Panel\Clock, Language and Region\Language\Advanced settings\Change Language Bar hotkeys; In the "Advanced Key Settings" tab, ...
Read more >Wrong Keyboard layout - reverts to US Eng Layout after restart
I have to reset it manually using the ENG in the task bar by the notification area. This of course then reverts when...
Read more >How to change keyboard layout on Windows 10
Windows 10 asks you to configure additional keyboard layouts during the initial setup. However, you can always add or remove layouts if you ......
Read more >Windows 10 keeps changing keyboard layout fix. - YouTube
Windows 10 keeps changing keyboard layout is very annoying. In this tutorial I am going to try to help You with this language...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Had same issue with swedish layout, fixed it with “locale=sv-SE”
Thansk for the mentin @Temez1. This was a very interesting read for me, as I have come to similar conclusions as @arnog over the past two years. Would have been very helpful to read these comments before that time.
Unfortunately, I don’t have much to add to the discussion. @stefnotch already mentions Keyboard.getLayoutMap(), which can be used to get a mapping from a key’s universal
code
to the layout-dependent character that’s printed on the user’s keyboard. KeyCombiner uses this to display a layout-specific virtual keyboard for each user. However, the API is only available on Chromium-based browsers and has other problems, too.In my experience, letting users define their own bindings is the only approach that kinda solves this problem for every possible layout and special case. They can just assign what works for them on their machine. Other approaches that I mentioned in my article (using
keypress
, the event’skey
property,…) could work well for simple apps, but make it very complicated when trying to provide support for many special characters, like I think MathLive is doing.