- Recognize the backspace and spacebar with jQuery
- $('body').keyup(function(e){
- if(e.keyCode == 8){
- // user has pressed backspace
- array.pop();
- }
- if(e.keyCode == 32){
- // user has pressed space
- array.push('');
- }
- });
- $(document).ready( function() {
- $('#inputid').bind('keypress', function(e) {
- if (e.which == 32){//space bar
- alert('space');
- }
- if (e.which == 8) {//backspace
- alert('back space');
- }
- });
- });