input 绑定回车事件

html
 
script
	function onKeyPress(e) {
		var keyCode = null;
	
		if(e.which)
			keyCode = e.which;
		else if(e.keyCode)
			keyCode = e.keyCode;
	
		if(keyCode == 13) {
			SendMessage();
			return false;
		}
		return true;
	}
	
	function SendMessage() {
		console.log(1)
	}

你可能感兴趣的:(javascript)