Guest User

Untitled

a guest
May 20th, 2012
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. Recognize the backspace and spacebar with jQuery
  2. $('body').keyup(function(e){
  3. if(e.keyCode == 8){
  4. // user has pressed backspace
  5. array.pop();
  6. }
  7. if(e.keyCode == 32){
  8. // user has pressed space
  9. array.push('');
  10. }
  11. });
  12.  
  13. $(document).ready( function() {
  14. $('#inputid').bind('keypress', function(e) {
  15. if (e.which == 32){//space bar
  16. alert('space');
  17. }
  18. if (e.which == 8) {//backspace
  19. alert('back space');
  20. }
  21. });
  22.  
  23.  
  24. });
Advertisement
Add Comment
Please, Sign In to add comment