Skip to content

UIEvent.instanceOf method

UIEvent › instanceOf

Official

Cross-window capable instanceof check, a drop-in replacement for instanceof checks on UIEvents.

Signature:

instanceOf(type: UIEventConstructor<T>): this is T

Parameters:

Parameter Type Description
type UIEventConstructor<T> The type to check.

Returns: this is TWhether the event is an instance of the type.

Example:

if (event.instanceOf(MouseEvent)) {
console.log('event is a mouse event');
}