Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

? doesn't work #130

Open
avigoldman opened this issue Nov 14, 2021 · 2 comments · May be fixed by #131
Open

? doesn't work #130

avigoldman opened this issue Nov 14, 2021 · 2 comments · May be fixed by #131

Comments

@avigoldman
Copy link

Hey! I'm running into an issue where I'd expect the following to fire when the ? is typed but it doesn't seem to be.

tinykeys(window, {
  "?": () => {
    alert("The '?' key was pressed")
  },
})

I believe it is getting filtered out here: https://github.com/jamiebuilds/tinykeys/blob/main/src/tinykeys.ts#L109

@avigoldman avigoldman linked a pull request Nov 14, 2021 that will close this issue
@ibash
Copy link

ibash commented Aug 27, 2022

For posterity, this happens because of the shift modifier. Mousetrap works around this by checking for characters that require shift is pressed:
https://github.com/ccampbell/mousetrap/blob/2f9a476ba6158ba69763e4fcf914966cc72ef433/mousetrap.js#L101

As a workaround, you can do Shift+? to have the shortcut match (this might not work for non-us keyboards).

@jamiebuilds
Copy link
Owner

jamiebuilds commented Aug 29, 2022

A future version of tinykeys should hopefully make use of the Keyboard.getLayoutMap() API, but as it is only supported by Chromium browsers you may want to use a dual approach of attempting to get the right codes from that API or mapping to the US keyboard if it is not available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants