Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 20th, 2012  |  syntax: None  |  size: 0.53 KB  |  hits: 29  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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.     });