使用热键基于快捷键触发按钮点击事件

Trigger button click event based on shortcut key using hotkey

我正在使用快捷方式功能的热键插件,我想在按下任何快捷方式时触发按钮点击。

hotkeys.add({
combo: 'alt+1',
callback: function (data) {
     data.preventDefault();
   " click "TakeAwayButton" here to call functionality of directive"
}
});

当我点击 Alt + 1 我想触发按钮点击。

按钮是:

<button type="button" id="TakeAwayButton" ng-click="orderType=1">Click Me </button>

你可以用jQueryLibrary.Check这个https://github.com/jeresig/jquery.hotkeys

只需使用click()函数:

Bind an event handler to the "click" JavaScript event, or trigger that event on an element.

hotkeys.add({
combo: 'alt+1',
callback: function (data) {
     data.preventDefault();
     $('#TakeAwayButton').click();
}
});