Hi all
I have two functions for my program:
function clickPlus() {
incrementCounterValueBy(1)
updateMessage()
}
function clickMinus() {
var currentValue
incrementCounterValueBy(-1)
}
How can I assign a keyboard shortcut to the function? I got mousetrap, but I can’t really figure it out.
Thanks so much in advance!
If you click + on your keyboard, it would call the function hello
Mousetrap.bind('+', function() {
hello('GiacomoLaw');
});
function hello(name) {
console.log(name);
}
1 Like
Okay, I’ll give it a go. Thank you!
Cowwy
March 8, 2017, 2:48pm
4
I am curious how this actually works, can you explain how scope binding would bind to a key?
From Github source , there is a prototype bind
method (source ) which calls _bindMultiple
which in turn calls _bindSingle
functions. I think this is how scope binding binds to the key pressed.