Comments (4)
Maybe accepting an array on the "when" parameter is a nice solution. We could make aliases for "combo" keys like ctrl, shift, alt, etc.
from react-event-components.
maybe we can find a better alternative for the array to try and keep a consistent syntax without using {}?
It's also an option to use a comma-separated string instead of the array, like it's implemented in this library:
https://github.com/madrobby/keymaster
So when={["w", "e", "r"]}
may be also represented as when="w, e, r"
. But personally I think that both options are viable. The comma-separated version is useful when you exactly know what you want, and the array version may be used when you want to generate the keys dynamically.
from react-event-components.
Ok, so, talking to @grvcoelho we agreed on a syntax:
when="w"
=> does what it does today
when={["w", "e", "r"]}
=> 'w', 'e', and 'r' would all trigger that action
when="shift+w"
=> would trigger only when 'shift' AND 'w' are pressed. You can also use this in arrays.
If anyone has a better idea lets work this through, otherwise I'll implement it this way :)
edit* maybe we can find a better alternative for the array to try and keep a consistent syntax without using {}?
from react-event-components.
I thought about the comma-separated string but I rather use the primitive types when they fit the needs, so if it's a list than it probably makes sense to use arrays :)
from react-event-components.
Related Issues (15)
- unsubscribe the event handler on unmount HOT 4
- All tests are failing HOT 4
- Which components are we missing? HOT 1
- Cannot use this package from npm with create-react-app HOT 4
- Which keyworks should we put in the package.json? HOT 1
- Improve code coverage HOT 2
- React.PropTypes is deprecated since React 15.5.0, use the npm module prop-types instead react/no-deprecated
- WindowResize example does not make sense
- Please make a new release HOT 2
- KeyDown modifier keys HOT 1
- Update dev dependencies HOT 2
- [fix] pass entire event to do callback so we can prevent default
- Can we elect a maintainer?
- `do` is a reserved word in javascript HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-event-components.