arnog / mathlive

A web component for easy math input
https://cortexjs.io/mathlive
MIT License
1.54k stars 269 forks source link

With an Italian layout keyboard, some keys do not work as expected #2292

Open chrostino opened 7 months ago

chrostino commented 7 months ago

Description

backslash / to trigger latex command broken on non US keyboard layout (ITA)

Steps to Reproduce

  1. using a non US keyboard layout (in my case an ITA‌ ISO layout)
  2. go to https://cortexjs.io/mathlive/demo/
  3. press the \ key to trigger latex commands list and write some symbols/something

Actual Behavior

the \ character is written and nothing happens, while if i press the key ù (which position overlaps with the position of the \ key on the US‌ ANSI layout) then latex commands are triggered as normal

Expected Behavior

ù key just writes the character and \ triggers latex commands

Environment

Is this a regression: did it use to work in a previous version?

MathLive version 0.98.6 Operating System Nobara 39

Browser Firefox

arnog commented 7 months ago

Do you have a QWERTY or QZERTY layout?

FYI, the supported keyboard layouts are here: https://github.com/arnog/mathlive/tree/master/src/editor/keyboard-layouts

If someone has the mapping for an Italian Linux keyboard, feel free to submit a PR.

chrostino commented 7 months ago

Thanks I didn't know different keyboard layouts needed to be supported it's a QWERTY layout (ITA ISO), it's the most common italian layout, here's a picture image

Leon-Lj commented 6 months ago

We've seen similar problems with Norwegian/Swedish keyboards, I've been meaning to create and submit layouts for those but have not found the time yet.

As a quick hack you can listen to the keyDown event and simply override the result.

if (evt.key === 'ù') {
  mf.insert('ù', { format: 'latex' });
  evt.preventDefault();
}
chrostino commented 5 months ago

I tried to make the italian one, mind I have like no experience so it is just a tentative but maybe it can be useful italian.txt