Home >Web Front-end >JS Tutorial >Javascript keyboard event combination usage implementation code_javascript skills

Javascript keyboard event combination usage implementation code_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:53:56908browse
Copy code The code is as follows:

txt1.onkeydown = function(ev){

var oevent = ev||event;

if(oevent.ctrlKey && oevent.keyCode == 13){
……
}
}

txt1: The object to which the event is bound, for example: a text input box input.

oevent: event object (contains many useful details of the event).

keyCode: You can get the key value pressed on the keyboard. For example: the Enter key is 13.

ctrlKey: is a Boolean value, indicating whether the ctrl key on the keyboard is pressed. (Of course: altKey, shiftKey).

The above code means: press the ctrl and enter keys to execute the statement in the ellipsis.
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