javascript keycodes 键盘键值

Posted by 任平生 on June 8, 2011

键盘 via:http://shikargar.wordpress.com/2010/10/27/javascript-key-codes/ 

在页面上增加键盘快捷键:

var inputFocus = false;  
$(':input').blur(function(){  
	inputFocus = false;  
});  
$(':input').focus(function(){  
	inputFocus = true;  
});  
$(document).keydown(function(e){  
	if(!inputFocus){  
		if(e.which == 87 && !e.ctrlKey){  
			//do something  
			return false;  
		}  
	}  
});