Test results of keyCode, which, and charCode compatibility in Keyboard Events:
In IE:
> Supports keyCode.
> Which and charCode are not supported. Their values are undefined.
In Firefox:
> Supports keyCode. Except for function keys, other key values are always 0.
> Which and charCode are supported. The values are the same.
In Opera:
> Supports
This article introduces a js user who presses the keyboard to display the keyCode instance. For more information, see.
Js instance
The Code is as follows:
Copy code
Of course, you can also use jquery event. which to obtain the user's keyboard value.
SyntaxEvent. which parameter descriptionEvent is required. Specifies the event to be checked. This event parameter comes from the event binding function.
JQuery discards th
Test the compatibility of keyCode, which, and charCode in Keyboard Events
Test Results:
In IE:
> Supports keyCode.
> Which and charCode are not supported. Their values are undefined.
In Firefox:
> Supports keyCode. Except for function keys, other key values are always 0.
> Which and charCode are supported. The values are the same.
In Opera:
> Supports
Test Results:In IE:> Supports keyCode.> Which and charCode are not supported. Their values are undefined.In Firefox:> Supports keyCode. Except for function keys, other key values are always 0.> Which and charCode are supported. The values are the same.In Opera:> Supports keyCode and which with the same values.> CharCode is not supported and its value is undefined
Window. event. keyCode is compatible with the specific implementation code of IE and Firefox as follows. If you are interested, refer to the following HTML code.
The Code is as follows:
Javascript code
The Code is as follows:
Function keyNumAll (evt ){// Compatible with IE and Firefox to obtain keyBoardEvent objectsEvt = (evt )? Evt: (window. event )? Window. event :"");Var key = evt. keyCode
When the user presses the ENTER key, the KeyEvent () function is executed. Can do a carriage return to submit the form, or other events!KeyCode is the code that returns the key to the KeyDown what KeyUp event occurred, and the Unicode character of the KeyPress event, and if you want to use a key combination, you can take advantage of event.ctrlkey,event.shiftkey,event. Altkey determines whether the CTRL key, the SHIFT key, and the ALT key are pressed.
triggering an event when a key is clickedDocument.onkeydown = function (e) {e = e | | event; if (E.KeyCode= = 13) {//Determine whether to click the Enter key (enter)Document.getelementbyidx_x_x ("txtID"). Click ();return false; }}Explanation: The value of KeyCode indicates the key of the corresponding keyboardKeyCode 8 = BackSpace BackSpaceKeyCode 9 = Tab tabKeyCode = ClearKeyCode = EnterKeyCode = shift_lKeyCode = control_lKeyCode = alt_lKeyCode = Pau
Test results:
Under IE:
>> Support KeyCode
>> does not support which and charcode, the values are undefined
Under Firefox:
>> supports keycode, except function keys, the other key values are always 0
>> supports which and charcode, the values are the same
Under Opera:
>> supports KeyCode and which, the values are the same
>> does not support charcode, value is
The difference between keyvalue and Keydata and KeyCode (turn)KeyPress eventsKeyPressEventArgs parametersHandled/Whether the KeyPress event has been processedKeyChar//press the key corresponding to the characterIf I, then Keychar is I, if shift+i, then Keychar is I.If it is ctrl+i, or alt+i, it will not get a KeyPress event, because they are special key sequences, not sent by KeyPress.Need KeyDownKeyDownKeyEventArgs parametersAlt gets a value that ind
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.