javascript Enter button trigger
javascript
$().ready(function(){
//Default Enter for search
document.addEvenListener('keydown',function(event){
if (event.keyCode === 13 ){
$('search').click();
}
});
});
查詢鍵盤 keyCode :
<!DOCTYPE>
<html>
<body>
<input type="text" size="40" onkeypress="searchFunction(event)">
<p id="demo"></p>
<script>
function searchFunction(event){
var x = event.keyCode;
//Key codes -> A number which represents an actual key on the keyboard
var y =String.fromCharCode(x);
//The fromCharCode() method converts Unicode values into characters.
//Character codes -> A number which represents an ASCII character
document.getElementById('demo').innerHTML = "Number : " + x + " = Character: " + y ;
}
</script>
</body>
</html>
參考網址 : W3