Search code examples
javascriptangularjshotkeys

Override browser shortcut keys while using angular jshotkeys


I am using angular hotkeys for handling shortcut using keyboard on my web page. But now i want to use ctrl + S to save my data. But when i try it shows web page save dialog. So, is there any way to override it in hotkeys framework.

Thanks in advance.


Solution

  • Assuming you are talking about this framework, you can probably just cancel the default effects of the associated event:

      hotkeys.add({
          combo: 'ctrl+s',
          description: 'Save my data',
          allowIn: ['INPUT', 'SELECT', 'TEXTAREA'],
          callback: function(event) {
              // (insert saving logic here)
              event.preventDefault();
          }
      });