event.type

Table of contents

  1. 1. Summary
  2. 2. Syntax
  3. 3. Examples
  4. 4. Specification
Table of contents
  1. 1. Summary
  2. 2. Syntax
  3. 3. Examples
  4. 4. Specification

Summary

Returns a string containing the type of event.

The event argument of element.addEventListener() and element.removeEventListener() is case insensitive.

For a list of available event types, see http://mdn.beonex.com/en/DOM/DOM_event_reference

Syntax

event.type

Examples

var string = event.type;
<html>
<head>

<title>type example</title>

<script type="text/javascript">
var currEvent = null;

function getEvtType(evt) {
  currEvent = evt.type;
  document.getElementById("Etype").firstChild.nodeValue = currEvent;
}

</script>
</head>

<body
  onkeydown="getEvtType(event)"
  onkeyup="getEvtType(event)"
  onmousedown="getEvtType(event)"
  onmouseup="getEvtType(event)">

<p>Press any key or click the mouse to get the event type.</p>
<p>Event type: <span id="Etype">-</span></p>

</body>
</html>

Specification

type

Tags (5)

Edit tags

Attachments (0)

 

Attach file