ObsoleteThis feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.
The UIEvent.isChar
read-only property returns a Boolean
indicating whether the event produced a key character or not.
Syntax
var isChar = UIEvent.isChar;
Value
A Boolean which is true
if the event produces a character; otherwise false
. Some keystroke combinations may raise events but not produce any character (example: ctrl-alt-?). When this is the case, isChar
returns false
. It is used when event handlers need to do something like echo the input on the screen.
Example
In this snippet, which is part of an event handler, the event is checked to see if it generates a character; if it does, the value of UIEvent.which
is appended to a string which buffers the typed characters.
if (event.isChar) { characterBuffer += e.which; }
Specification
This property is not part of any specification.
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Chrome
No support No |
Edge
No support No |
Firefox No support ? — 55 No support ? — 55 Notes' The |
IE
No support No |
Opera
No support No |
Safari
No support No |
WebView Android
No support No |
Chrome Android
No support No |
Firefox Android No support ? — 55 No support ? — 55 Notes' The |
Opera Android
No support No |
Safari iOS
No support No |
Samsung Internet Android
No support No |
Legend
- No support
- No support
- Non-standard. Expect poor cross-browser support.'
- Non-standard. Expect poor cross-browser support.
- Deprecated. Not for use in new websites.'
- Deprecated. Not for use in new websites.
- See implementation notes.'
- See implementation notes.
See also
UIEvent.isChar by Mozilla Contributors is licensed under CC-BY-SA 2.5.