2 * Assign access keys to <a> tags.
4 * Access key action is peformed via .click(). hrefs, routerLinks,
5 * and (click) actions are all supported.
8 * routerLink="/staff/splash"
10 * keySpec="alt+h" i18n-keySpec
11 * keyDesc="My Description" 18n-keyDesc
14 import {Directive, ElementRef, Input, OnInit} from '@angular/core';
15 import {AccessKeyService} from '@eg/share/accesskey/accesskey.service';
18 selector: '[egAccessKey]'
20 export class AccessKeyDirective implements OnInit {
22 // Space-separated list of key combinations
23 // E.g. "ctrl+h", "alt+h ctrl+y"
24 @Input() keySpec: string;
26 // Description to display in the accesskey info dialog
27 @Input() keyDesc: string;
29 // Context info to display in the accesskey info dialog
31 @Input() keyCtx: string;
34 private elm: ElementRef,
35 private keyService: AccessKeyService
41 console.warn('AccessKey no keySpec provided');
45 this.keySpec.split(/ /).forEach(keySpec => {
46 this.keyService.assign({
50 action: () => this.elm.nativeElement.click()