Home >Web Front-end >JS Tutorial >js binding keyboard and mouse events sample code_javascript skills

js binding keyboard and mouse events sample code_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:00:281351browse

1. Bind the keyboard Enter event (Note: When submitting with jq, you can submit by pressing the Enter key at the same time. Do not use form at this time.)

Copy code The code is as follows:

document.onkeydown = function(evt){
var evt = window.event?window.event:evt;
if (evt.keyCode==13){
subcomment(); //If the Enter key is pressed, the corresponding js function is executed
}
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn