This simple code does not work! http://jsfiddle.net/FPcFn/
$(document).keydown(function(e){ switch (e.which){ case 37: alert("37"); } });
Why? What could go wrong?
It works. Click in the output window and press the left arrow.
Use window instead of document .
window
document
$(window).keydown(function(e){ .. }
PS: Recommended to use document . keydown event is available both with documents and with a window. Take a look at the tables.
keydown
Source: https://habr.com/ru/post/903823/More articles:How to filter only images and videos in the Android gallery? - androidHow to bind an event with using backbone.js? - javascriptredirecting output to a file in C - linuxa malfunction on the body? - javascriptQuadratic matrix sparse matrix multiplication algorithm - c ++Setting background color for SurfaceView in Android - androidhow to set backgroundColor to view surface in android? - androidAny kind of treatment. * How. {0,1024} in perl RE? - optimizationDisable printing in python unittest - pythonWhy does the session not end when the browser closes when session.cookie_lifetime = 0? - phpAll Articles