skalar / ember-keyboard-shortcuts Goto Github PK
View Code? Open in Web Editor NEWEmber addon that uses mousetrap to facilitate keyboard shortcuts.
License: MIT License
Ember addon that uses mousetrap to facilitate keyboard shortcuts.
License: MIT License
How come we have to install this via github? Seems a npm install --save ember-keyboard-shortcuts
would be easier and you can search npmjs.com for it with the ember-addon keyword or via http://www.emberaddons.com/
Please consider publishing to NPM (npm publish
). Thanks.
I recently tried to upgrade from 0.3.0 to version 1.0.1 to get rid of the event storms that caused me trouble.
However it stopped working when using keyboardShortcuts on a route. I get the error Cannot read property 'bind' of undefined.
It seems as mousetrap is not defined when reaching mousetrap.bind inside the invokeAction method in create-mixin.js. The error is simple to reproduce with the following simple shortcut to an action set:
keyboardShortcuts: {
'esc': 'cancel'
}
I can see that mousetrap is not initialized on declaration as it was before. Since my actionObject is global, not scoped and does not have a targetElement it will not get into any of the if statements where mousetrap is set.
Using this cool addon causes a "bower 1.8.0 is deprecated" warning in Ember 2.12, since you have to add "[email protected]" in your ember package.json dependency list to fetch all bower stuff.
Could the single bower to "mousetrap": "~1.5.2" be replaced by the NPM equivalent? I didn't investigate beyond checking that there's a package in NPM (see https://www.npmjs.com/package/mousetrap) that does the same.
First, thank you for developing this awesome plugin ๐
One thing I'd like to do is be able to use a sequence of keys to trigger an action. Similar to what can be done in vim.
E.g. Pressing g twice in short-succession to trigger an action.
Is this possible?
preventDefault: true // (default: true)rue
It makes sense to migrate to Typescript to improve interop with users of Typescript.
Hi, can you please create a 0.4.0 release for the master branch please?
Thanks in advance!
@trym great addon. are you planning on maintaining it going forward? I noticed there are some longstanding PRs and Mousetrap is now at 1.5.3.
If you don't have the time, I'd be more than happy to help maintain it if you add me as a contributor. If not, I'll probably go ahead and just maintain my own fork.
Thanks!
to clear event listener we are using mousetrap._handleKeyEvent
which is actually not defined ( it is private to the library ).
so basically, when assigning on a component, we will be leaking DOM nodes because of that.
The only way I can see to do that is to clone moustrap
somewhere, add a function to cleanup ( moving the cleanup code from this addon to mousetrap ), create a PR and wait for it to be accepeted.
In the mean time, we can use the cloned moustrap to fix this issue.
Hey great job making mousetrap ember friendly ๐
When a shortcut is scoped to a component, can we have a blacklist class names under which it won't fire.
For example, let's say there is a post
component which has 2 content editable's, one for writing post and other for previewing posts. I don't want the shortcuts that is working for the first content editable working when the user is inside the preview content editable. Here, global
attribute for shortcuts is set to true so as to make shortcuts work inside a content editable.
In this case, I can blacklist the preview content editable's class post-preview
, so that the shortcut triggers inside all post component but not inside preview content editable.
The README says keyboard shortcuts can be used on Routes, Controllers and Components, but only gives examples for Routes and Components. (I'm new to Ember and so only vaguely aware of the controllers-will-be-deprecated message, if that's the reason.)
I think the Controller equivalent is to call bindKeyboardShortcuts() inside the init() hook.
Hi,
Is there anyway to re-route within the component instead of via a route?
What is then the point to add the keyboard shortcuts to the component if we still need to also add the functions in the route? Unless I'm missing something? I don't want to have to repeat my "actions" in each route. I'd like to contain all of this in my component. Is it possible?
Thank you!
With the changes of #25, mixins usage should be deprecated.
Hello! Cool addon but is it working with ember and ember-data 2.x?
hi ..I was just tried to use this addon in my application route and tried to bind and unbind shortcuts depending on one boolean value that has been set to false initially in one service file..
The value of that boolean in that service will toogle to false and true based on some actions.
I haven't used the hooks namely activate and deactivate because it is my application route so the deactivate hook will not trigger in there.I simply used methods bindKeyboardShortcuts
, unbindKeyboardShortcuts
.But when I tried to do this I'm getting some errors.
My application:
In this file when I click on t it should call action "sayHello" which is in my test-mixin which will simply alert"hello".
why the above mentioned errors are occuring.?
It will be better if the shortcuts can be handled only by those bindKeyboardShortcuts
, unbindKeyboardShortcuts
methods and not by the activate and deactivate hooks.because the developer knows when to unbind and bind nevertheless he gets to another route or he stays in the same route.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.