Skip to content

Create bindings using KeyboardEvent#code value #33

Description

@vladdekhanov

Describe the bug
Library doesn't support code or which property to make hotkey language agnostic. It compare event key by value due to works with only one keyboard layout.

To Reproduce
Imagine you have keyboard with 2 layouts: native language and english (i.e. French and English).

Steps to reproduce the behavior:

  1. Bind event
import { bindKey } from '@rwh/keystrokes'

bindKey('H', {
	onPressed: () => {
		...
	},
	onReleased: () => {
		...
	},
});
  1. Press H button in English layout. It works
  2. Change active keybord layout to French. Press physically same button. It doesn't work what is obviously is not clear for any user.

Expected behavior
Library should work with code property (physical id of the button) and not with a key (it contains value, changable thing), otherwise library would be used only for few countries where people use english as a native language.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions