Giter VIP home page Giter VIP logo

Comments (4)

MarcoWorms avatar MarcoWorms commented on May 26, 2024 1

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.

anatoliyarkhipov avatar anatoliyarkhipov commented on May 26, 2024 1

@MarcoWorms

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.

MarcoWorms avatar MarcoWorms commented on May 26, 2024

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 :)

@derekstavis

edit* maybe we can find a better alternative for the array to try and keep a consistent syntax without using {}?

from react-event-components.

MarcoWorms avatar MarcoWorms commented on May 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.