Knockout.js div或Section上的按键事件
附加按键事件: 我的视图模型:Knockout.js div或Section上的按键事件,knockout.js,Knockout.js,附加按键事件: 我的视图模型: Billing.BillingViewModel = function () { this.showSearcherCustomerKeyCommand = function (data, event) { if (event.shiftKey && event.keyCode == 49) { alert("Combination done !"); } }; }; <
Billing.BillingViewModel = function () {
this.showSearcherCustomerKeyCommand = function (data, event) {
if (event.shiftKey && event.keyCode == 49) {
alert("Combination done !");
}
};
};
<section id="BillHeaderSecction" data-bind="event: { keypress: billingClient.showSearcherCustomerKeyCommand }, valueupdate: 'afterkeydown'">
HTML上的Section标记:
Billing.BillingViewModel = function () {
this.showSearcherCustomerKeyCommand = function (data, event) {
if (event.shiftKey && event.keyCode == 49) {
alert("Combination done !");
}
};
};
<section id="BillHeaderSecction" data-bind="event: { keypress: billingClient.showSearcherCustomerKeyCommand }, valueupdate: 'afterkeydown'">
但当我根据自己的要求进行组合时,事件不会执行。如何将knockout中的事件附加到div、section等,而不是输入。谢谢 关键事件将在节或div有焦点时起作用。将tabindex=“0”指定给div元素,并聚焦该特定div,然后按任意键,键事件将起作用。
在此处输入代码
您不能这样做,因为按键
与相关,并且。
您可以尝试使用鼠标悬停和鼠标悬停
。如果需要的话,试着这样做。干杯,但当最终用户使用ctrl+1组合键时,我需要它。。。不管怎样,我的应用程序可以做一些事情,比如显示弹出窗口、隐藏模式、设置焦点等等。。。击倒是不可能的???据我所知,我们不能基于部分或div的键附加事件。