Javascript examples for jQuery Method and Property:keyup
Keydown + keyup events for specific keys
<html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> </head> <body> <script> $(document).ready(function () { $('body').on('keydown keyup',function(e){ var color = e.type=="keydown" ? 'red' : 'white' ; if(e.which==82){// w w w . jav a 2s. c o m $(this).css({background: color}); } }); }); </script> </body> </html>