1 import { Hotkey, HotkeysService } from 'angular2-hotkeys'
2 import { Subscription } from 'rxjs'
3 import { Component, Input, OnDestroy, OnInit } from '@angular/core'
6 selector : 'my-hotkeys-cheatsheet',
7 templateUrl : './hotkeys.component.html',
8 styleUrls: [ './hotkeys.component.scss' ]
10 export class CheatSheetComponent implements OnInit, OnDestroy {
11 @Input() title = $localize`Keyboard Shortcuts:`
13 subscription: Subscription
18 private hotkeysService: HotkeysService
21 public ngOnInit (): void {
22 this.subscription = this.hotkeysService.cheatSheetToggle.subscribe((isOpen) => {
23 if (isOpen !== false) {
24 this.hotkeys = this.hotkeysService.hotkeys.filter(hotkey => hotkey.description)
27 if (isOpen === false) {
28 this.helpVisible = false
30 this.toggleHelpVisible()
35 public ngOnDestroy (): void {
36 if (this.subscription) {
37 this.subscription.unsubscribe()
41 public toggleCheatSheet (): void {
42 this.hotkeysService.cheatSheetToggle.next(!this.helpVisible)
45 public toggleHelpVisible (): void {
46 this.helpVisible = !this.helpVisible