在jquery中处理键事件(cntrl + z) [英] handle key events (cntrl+z) in jquery
本文介绍了在jquery中处理键事件(cntrl + z)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用jquery代码执行cntrl + z似乎很好但是它不起作用。
任何人都可以帮我这个。
我的代码是如下:
$(文件).keydown(函数(e){
if(e.keyCode == 90 && e.ctrlKey) )
{
alert('cnttrl z pressed');
}
});
尝试将90单引号'90'不起作用
试过(e.keyCode == 90 && e.keyCode == 17)不工作
尝试过keyup而不是keydown不工作
提前谢谢
I want to execute cntrl+z using jquery code seems to be fine but its not working.
can anyone help me with this please.
My code is as follows:
$(document).keydown(function(e){
if(e.keyCode==90 && e.ctrlKey)
{
alert('cnttrl z pressed');
}
});
tried putting 90 in single quotes '90' not working
tried (e.keyCode==90 && e.keyCode==17) not working
tried keyup instead of keydown not working
Thanks in advance
推荐答案
(document).keydown(function(e){
if(e.keyCode == 90 && e.ctrlKey)
{
警报('cnttrl z press');
}
});
尝试将90个单独放入引号'90'不工作
试过(e.keyCode == 90 && e.keyCode == 17)不工作
尝试过keyup而不是keydown不工作>
提前致谢
(document).keydown(function(e){
if(e.keyCode==90 && e.ctrlKey)
{
alert('cnttrl z pressed');
}
});
tried putting 90 in single quotes '90' not working
tried (e.keyCode==90 && e.keyCode==17) not working
tried keyup instead of keydown not working
Thanks in advance
您好,
您的代码也适用于我。这是我使用你的代码的方式:
Hi,
Your code works fine for me too. This is the way I used your code:
( document )。ready( function (){
(document).ready(function () {
这篇关于在jquery中处理键事件(cntrl + z)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文