Changes between Initial Version and Version 1 of Ticket #19489, comment 6
- Timestamp:
- 09/02/2013 10:36:07 AM (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #19489, comment 6
initial v1 1 1 I have been having trouble getting this plugin to work properly -- it kept binding all the keys at once no matter what key I set. Because of this, hitting any key would trigger my alert "hello." It took two days to find what was wrong, but this code below should work for everyone, where 'S' is the key you chose to keydown (or up) upon: 2 2 {{{ 3 3 jQuery(document).bind('keydown', function (e){ 4 4 if (String.fromCharCode(e.keyCode) == 'S') { 5 alert('hello');6 e.preventDefault();7 return false;8 5 alert('hello'); 6 e.preventDefault(); 7 return false; 8 } 9 9 }); 10 10 }}} 11 11 12 12 Hope this is helpful to someone!