Open martpie opened 8 years ago
From #8: more generally, we should probably have a way to support accelerators (example: "CmdOrCtrl+A").
Any chance we could add Shift
to modifier list?
Checking in if we can get the modifiers soon so we can add this library to our entire platform 🙏
The keyboard event is passed to the callback, so you can do the following right now:
onKey={(e) => {
if (e.shiftKey) {
// ... same with e.metaKey, ctrlKey, altKey, etc
}
}}
The keyboard event is passed to the callback, so you can do the following right now:
onKey={(e) => { if (e.shiftKey) { // ... same with e.metaKey, ctrlKey, altKey, etc } }}
Maybe i'm doing it wrong, but it doesn't seem like it lets me do combinations, right?
Like Shift + 1 Shift + 2 etc
You can build any kind of combination you need because you have the keyboard event object with all the information needed to filter by key or modifier.
Here’s a real life example on one of my projects:
https://github.com/martpie/museeks/blob/master/src/components/TracksList/TracksList.tsx#L164-L202
Actually there's no "easy key mapping" like https://github.com/mapbox/react-keybinding#api
Think about a way to add them.
ideas: