Comments (7)
@thekalinga Please find the example code here
(https://github.com/mhussain001/angular2-webpack-starter)
from angular2-hotkeys.
@mhussain001 Can u point me to a class within the other project where you have implemented this.
Also, it has to be documented in this project
from angular2-hotkeys.
@thekalinga Please refer https://github.com/mhussain001/angular2-webpack-starter/blob/master/src/app/app.component.ts
from angular2-hotkeys.
This is the way you register a global hotkey. But, the question talks about binding a hotkey such that the hotkey's life cycle is bound to the lifecycle of the component, not the whole app.
from angular2-hotkeys.
One way to do this is to add
(register) and remove
(unregister) in each of the component manually in OnInit
& OnDestroy
where I need component scoped hotkeys, so that the shortcuts are scoped only to the component.
I believe it should be done in a better way where the hotkey framework itself does the removal of this shortcut under the hood by removing the shortcut as soon as the onDestory
is called on the component using the service.
I have just added a question in stackoverflow to see if Angular allows us to do this
from angular2-hotkeys.
@thekalinga did you achieve it ? i really need this one.
from angular2-hotkeys.
Yes, OnInit
& OnDestroy
is the recommended way for creating component scoped hotkeys
from angular2-hotkeys.
Related Issues (20)
- Cannot find name 'MousetrapInstance' HOT 1
- `cannot find mousetrap` issue fix .Kindly update HOT 1
- Unable to remove(unbind) the hotkey with the specific event
- Angular 12 compatibility HOT 8
- Is it possible to prevent hotkeys being active in a material select? HOT 1
- how to remove all listener on destroy HOT 2
- Angular 13 compatibility HOT 6
- Angular 13.1.1 compilation error with mousestrap HOT 3
- Publish an Ivy distribution HOT 2
- Can cheatsheethotkey define string[]? HOT 2
- Angular 14 compatibility HOT 3
- Cypress clicks on hidden hotkeys-cheatsheet component HOT 1
- Hotkey params not being passed to mousetrap?
- 13.2.0 not working properly HOT 4
- After updating to v15.0.0, a type definition error regarding mousetrap occurs. HOT 3
- Is it compatible with Angular v16+ HOT 6
- Angular build warning: Mousetrap commonjs dependency HOT 1
- Angular 17 support HOT 1
- Property '"title"' is incompatible with index signature.
- Unit tests failing with the error - No provider for InjectionToken HotkeyOptions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular2-hotkeys.