[英]Detect Shift key + click event on iCheck checkbox
My web page uses iCheck
checkboxes. 我的网页使用
iCheck
复选框。 I am trying to get event when Shift
key is pressed along with clicking on checkboxes. 我试图在
Shift
键的同时单击复选框来获取事件。 but no where in the documentation, iCheck
gives that notification like normal document.click(function())
gives. 但在文档中没有任何地方,
iCheck
会像普通document.click(function())
一样给出该通知。
I am using 我在用
$('input[name=selectinp]').on('ifChanged', function(event){
...
});
Here, event.shiftkey is undefined. 在这里, event.shiftkey是未定义的。 Please help.
请帮忙。
I know this is an old question, but I will answer it to help any future folks that are looking for solutions. 我知道这是一个古老的问题,但是我会回答这个问题,以帮助正在寻找解决方案的任何将来的人们。 The iCheck library does not pass through the entire click event, so you can't check for
event.shiftKey
. iCheck库不会传递整个click事件,因此您无法检查
event.shiftKey
。 Instead, you have to manually build your own variable that stores whether the shift key is pressed or not: 相反,您必须手动构建自己的变量,该变量存储是否按下Shift键:
var shiftIsPressed = false;
$(window).keydown(keyDownHandler);
$(window).keyup(keyUpHandler);
function keyDownHandler(event) {
if (event.key == "Shift") {
shiftIsPressed = true;
}
}
function keyUpHandler(event) {
if (event.key == "Shift") {
shiftIsPressed = false;
}
}
$('input[name=selectinp]').on('ifChanged', function(event){
if (shiftIsPressed) {
...
} else {
...
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.