mousetrap
mousetrap copied to clipboard
added mouseup action
I implemented
- leftclick
- middleclick
- rightclick
Now it's possible to watch for clicks.
Mousetrap.bind('ctrl+leftclick', function() {
console.log('ctrl was pressed while left click');
});
Currently I have no idea how to implement tests for this, because I don't know how to fire MouseEvents and KeyboardEvent together.
+1 Would love to see mouse support added, mousewheel support would be a nice addition to this as well.
A package to simplify the management of hotkeys cannot be complete without this. Many applications have default clicking/scrolling actions and when key modifiers are pressed, they might do something else. For instance, in a painting application, scrolling could change the brush size or zoom level depending on if a key is pressed.
Worth noting however, that while this PR works well with modifiers like ctrl, shift, alt - it doesn't appear to work properly with other keys. For instance a+leftclick
will fire on every LMB mouseup event, it doesn't seem to check that the a
key is pressed. Also, you're listening to mouseup but calling it a 'click', which is technically incorrect. There should be down, move, up, and click event handling if it were to be implemented properly.
(+1)
(+1)
Any updates on this?
+1