简体   繁体   中英

How to detect Ctrl+S shortcut key in Angular?

I want to detect the Ctrl+S shortcut key in Angular. How many ways can you write it? In this article, the author mentioned that we can detect using three methods. But I can not figure out how to use any of those to detect the Ctrl+S event.

For me, the best case scenario is using @HostListener for the event, by listening on document Element. but I can't figure out the Ctrl+S event.

check this:

 @HostListener('document:keydown.control.s', ['$event']) onKeydownHandler(event: KeyboardEvent) {
    event.preventDefault();
    console.log('CTRL + S');
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM