mantinedev / mantine

A fully featured React components library
https://mantine.dev
MIT License
26.79k stars 1.9k forks source link

useHotkeys does not listen to Spacebar key `" "` #6831

Closed Jacouille closed 1 month ago

Jacouille commented 1 month ago

Dependencies check up

What version of @mantine/* packages do you have in package.json?

7.12.2

What package has an issue?

@mantine/hooks

What framework do you use?

Next.js

In which browsers you can reproduce the issue?

All

Describe the bug

The useHotkeys hook does not listen to the " " spacebar key. It seems that during the key parsing, we trim spaces causing the resulting space key to be no key. The Spacebar key code was used in older browsers but now they seem to all use the " " key code

If possible, include a link to a codesandbox with a minimal reproduction

No response

Possible fix

An easy fix would be to add an option in the HotkeyItemOptions to prevent trimming while parsing the key. This way we'd maintain backward compatibility and the space key would work.

Self-service

Kenzo-Wada commented 1 month ago

I think "space" works fine:)

Jacouille commented 1 month ago

Yeah you're right! I can't find the documentation on MDN saying the space code works as well. Thanks!