W3cubDocs

/DOM

UIEvent.isChar

Obsolete
This 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 compatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
Basic support No No ? — 55
? — 55
The isChar property has never been supported by any browser but Firefox, and even on Firefox it's never worked except on Mac OSX. For that reason, it's been removed in Firefox 55 to align with other browsers.
No No No
Mobile
Android webview Chrome for Android Edge Mobile Firefox for Android Opera for Android iOS Safari Samsung Internet
Basic support No No No ? — 55
? — 55
The isChar property has never been supported by any browser but Firefox, and even on Firefox it's never worked except on Mac OSX. For that reason, it's been removed in Firefox 55 to align with other browsers.
No No No

See also

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/isChar