I have used keyDown event to manage the input tag value by judge e.keycode,
but when I want use keyDown event do something on body element or img ,
I found it doesn’t work,like :
$('body,img').keyDown(function(e){
console.log(e.keyCode);
});
Does keyDown event only work for input tag?
The keyDown event only works for focusable elements. This would include input fields, textareas, etc., but you’re probably not going to find any browser support for the
imgelement. From the jQuery docs:You may also be interested in this related question: Which HTML elements can receive focus?