Git Product home page Git Product logo

Comments (2)

keithamus avatar keithamus commented on July 30, 2024

At current there is no "easy" way to do mass key bindings, other than using jwerty.is.

I have been considering the issue of mass-keybindings though, before this issue. My proposal is to allow an object mapping of keys to functions, allowing you to do something like this:

jwerty.key('myinput', {

    'ctrl+shift+a': false,
    'ctrl+shift+x': function () { console.log('ctrl shift x'); },
    'ctrl+shift+p': myFunction

});

However for repetitive tasks, that mostly do the same thing with a few minor exceptions, this doesn't really improve anything.

I'd like to see your use code though, how you're using it and what you think would improve the terseness.

from jwerty.

marcbourlon avatar marcbourlon commented on July 30, 2024

HI Keith,

Thanks for the answer. While posting the issue, I thought that maybe I was not doing things optimally.
I'm doing a webapp, in which I use key combos (and for this, jwerty just rocks), but also single keypresses. I don't feel comfortable at adding my own keydown events, so I had to do it to detect single dead keys, as posted in another issue (how, with jwerty, would you use a dead key to enable a specific mode of your app? Like: normal mouse action is drawing, but if I press Ctrl, same mouse action will result in moving elements? I need a keydown and a keyup callbacks, and as of now, had to do with my own (crappy) code. Though this is another issue, it also comes to the fact I need to "complete" Jwerty, which is a bit less elegant for me.
As for the current issue, here's my need: I use the same callback for two keys (v and h namely), and use the key as an object property, to make it simple.
I have something like:

Jwerty.key('v/h', myCallback);

function myCallback(e) {
var key=Key.getKey(e);

MyObject[key] = "foobar";
}

from jwerty.

Related Issues (20)

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.