plate icon indicating copy to clipboard operation
plate copied to clipboard

Can't use accent non ascii hotkey

Open jgirardet opened this issue 3 years ago • 5 comments

Description

Can't use any non ascii hotkey

Sandbox Example sandbox

I added many hotkeys to MARK_BOLD mod+e and mod+b works. mod+é and mod+! doesn't work I tried "mod+2", it works. on french keyboard é is the default key for 2 in qwerty(numbers need shift)

It seems to work on slate.

Environment "dependencies": { "@udecode/slate-plugins": "^1.0.0-alpha.25", "react": "^17.0.2", "react-dom": "^17.0.2", "slate": "^0.62.0", "slate-history": "^0.62.0", "slate-hyperscript": "^0.62.0", "slate-react": "^0.62.0" }, ubuntu 20.04 Firefox 88

jgirardet avatar May 03 '21 22:05 jgirardet

We're currently using is-hotkey. I plan to move to https://github.com/jaywcjlove/hotkeys

zbeyens avatar May 04 '21 00:05 zbeyens

slate also use https://github.com/ianstormtaylor/is-hotkey/blob/master/src/index.js and it's ok some I'm not sure it's related to that. I try to investigate the code base but I'm lost, could you tell me where I could search for further experiment ?

jgirardet avatar May 04 '21 06:05 jgirardet

This is where it's used https://github.com/udecode/slate-plugins/blob/8c94295c0a0871d7934be692286b1a66db6ef372/packages/common/src/utils/getToggleMarkOnKeyDown.ts#L16

Maybe try is-hotkey on a sandbox?

zbeyens avatar May 04 '21 14:05 zbeyens

Ok it's not a bug it's a feature :()

isHotkey works like that.

By default the hotkey string is checked using event.which. But you can also pass in byKey: true to compare using the KeyboardEvent.key API, which stays the same regardless of keyboard layout.

So do we want to support to support event.key ? I think we should and it should be default since which is deprecated : https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/which

When ? : maybe after moving to hotkeys lib.

But since which is deprecated, key should become the default in slate-plugins. That's a hug break to the API that should be done before 1.0

jgirardet avatar May 04 '21 19:05 jgirardet

OK for the new default. Added to #672

zbeyens avatar May 04 '21 21:05 zbeyens