evilmartians / oklch-picker

Color Picker for LCH
https://oklch.com
Other
849 stars 65 forks source link

Work with hotkeys on different keyboard layouts #32

Closed ai closed 2 years ago

ai commented 2 years ago
  1. Switch to Russian layout
  2. Press L (Д)

Expected result: L field focus.

Current result: no focus.

redly commented 2 years ago

You could try to replace e.key inside keydown events with e.code which will return KeyL (for your example) value for all different layouts. e.code value is not affected by the current keyboard layout or modifier state, so it will always return the same value

And

let hotkey = field.querySelector('kbd')!.innerText.trim().toLowerCase()
hotkeys[hotkey] = input

could be replaced by

let hotkey = `Key${field.querySelector('kbd')!.innerText.trim().toUpperCase()}`
hotkeys[hotkey] = input
ai commented 2 years ago

@redly can you try to send PR to save your name in the project’s history?

redly commented 2 years ago

@redly can you try to send PR to save your name in the project’s history?

@ai Open a new PR #40 with bug fix