From 679615ebb1fc2c166da3f2b5d3d72e8c3a7acd8c Mon Sep 17 00:00:00 2001 From: wittlock <1336118+wittlock@users.noreply.github.com> Date: Mon, 12 Feb 2018 20:36:36 +0100 Subject: [PATCH 1/4] Added a configuration to IHotkeyOptions to change the description for the "ESC to close" shortcut on the cheat sheet, when enabled. Relates to issue #50, #56, #64 --- src/hotkey.options.ts | 4 ++++ src/hotkeys.service.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/hotkey.options.ts b/src/hotkey.options.ts index 3a16043..2d947b3 100644 --- a/src/hotkey.options.ts +++ b/src/hotkey.options.ts @@ -14,6 +14,10 @@ export interface IHotkeyOptions { * Use also ESC for closing the cheat sheet. Default: false */ cheatSheetCloseEsc?: boolean; + /** + * Description for the ESC key for closing the cheat sheet (if enabed). Default: 'Hide this help menu' + */ + cheatSheetCloseEscDescription?: string; /** * Description for the cheat sheet hot key in the cheat sheet. Default: 'Show / hide this help menu' */ diff --git a/src/hotkeys.service.ts b/src/hotkeys.service.ts index a4d12d4..1da26bc 100644 --- a/src/hotkeys.service.ts +++ b/src/hotkeys.service.ts @@ -40,7 +40,7 @@ export class HotkeysService { this.cheatSheetToggle.next(false); }.bind(this), ['HOTKEYS-CHEATSHEET'], - 'Hide this help menu', + this.options.cheatSheetCloseEscDescription || 'Hide this help menu', )); } From c8958833456a83e80f4829f94ff254112281f9d5 Mon Sep 17 00:00:00 2001 From: wittlock <1336118+wittlock@users.noreply.github.com> Date: Mon, 12 Feb 2018 20:56:03 +0100 Subject: [PATCH 2/4] Updated documentation to reflect the new setting available. --- README.MD | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.MD b/README.MD index 5229aa2..148cc77 100644 --- a/README.MD +++ b/README.MD @@ -83,6 +83,10 @@ export interface IHotkeyOptions { * Use also ESC for closing the cheat sheet. Default: false */ cheatSheetCloseEsc?: boolean; + /** + * Description for the ESC key for closing the cheat sheet (if enabed). Default: 'Hide this help menu' + */ + cheatSheetCloseEscDescription?: string; /** * Description for the cheat sheet hot key in the cheat sheet. Default: 'Show / hide this help menu' */ From 707c294889cea59822d0b0291f2bb7fe78086c20 Mon Sep 17 00:00:00 2001 From: wittlock <1336118+wittlock@users.noreply.github.com> Date: Mon, 12 Feb 2018 20:56:50 +0100 Subject: [PATCH 3/4] Updated README.MD with a blurb about how Hotkeys must have a description to show up in the cheat sheet. In reference to issue #63 --- README.MD | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.MD b/README.MD index 148cc77..d732c93 100644 --- a/README.MD +++ b/README.MD @@ -65,6 +65,18 @@ Based off of the [angular-hotkeys library](https://github.com/chieffancypants/an To enable the cheat sheet, simply add `` to your top level component template. The `HotkeysService` will automatically register the `?` key combo to toggle the cheat sheet. +**NB!** Only hotkeys that have a description will apear on the cheat sheet. The Hotkey constructor takes a description as +an optional fourth parameter as a string or optionally as a function for dynamic descriptions. + +```typescript + this._hotkeysService.add(new Hotkey('meta+shift+g', (event: KeyboardEvent): boolean => { + console.log('Secret message'); + return false; + }, undefined, 'Send a secret message to the console.')); +``` + +The third parameter, given as `undefined`, can be used to allow the Hotkey to fire in INPUT, SELECT or TEXTAREA tags. + ### Cheat Sheet Customization 1. You can now pass in custom options in `HotkeysModule.forRoot(options: IHotkeyOptions)`. From 9302c1c9133ac85f4d0641352d7b50cffc968e4a Mon Sep 17 00:00:00 2001 From: wittlock <1336118+wittlock@users.noreply.github.com> Date: Mon, 12 Feb 2018 20:57:54 +0100 Subject: [PATCH 4/4] Formatting tweaks --- README.MD | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.MD b/README.MD index d732c93..722f02c 100644 --- a/README.MD +++ b/README.MD @@ -69,10 +69,10 @@ The `HotkeysService` will automatically register the `?` key combo to toggle the an optional fourth parameter as a string or optionally as a function for dynamic descriptions. ```typescript - this._hotkeysService.add(new Hotkey('meta+shift+g', (event: KeyboardEvent): boolean => { - console.log('Secret message'); - return false; - }, undefined, 'Send a secret message to the console.')); +this._hotkeysService.add(new Hotkey('meta+shift+g', (event: KeyboardEvent): boolean => { + console.log('Secret message'); + return false; +}, undefined, 'Send a secret message to the console.')); ``` The third parameter, given as `undefined`, can be used to allow the Hotkey to fire in INPUT, SELECT or TEXTAREA tags. @@ -96,8 +96,8 @@ export interface IHotkeyOptions { */ cheatSheetCloseEsc?: boolean; /** - * Description for the ESC key for closing the cheat sheet (if enabed). Default: 'Hide this help menu' - */ + * Description for the ESC key for closing the cheat sheet (if enabed). Default: 'Hide this help menu' + */ cheatSheetCloseEscDescription?: string; /** * Description for the cheat sheet hot key in the cheat sheet. Default: 'Show / hide this help menu'