event.type

  • Revision slug: DOM/event.type
  • Revision title: event.type
  • Revision id: 7998
  • Created:
  • Creator: dbruant
  • Is current revision? No
  • Comment formating; 13 words removed

Revision Content

Summary

Returns a string containing the type of event.

The event argument of {{ domxref("element.addEventListener()") }} and {{ domxref("element.removeEventListener()") }} is case insensitive.

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

{{ languages( { "pl": "pl/DOM/event.type" } ) }}

Revision Source

<h2 name="Summary">Summary</h2>
<p>Returns a string containing the type of event.</p>
<p>The event argument of {{ domxref("element.addEventListener()") }} and {{ domxref("element.removeEventListener()") }} is case insensitive.</p>
<h2 name="Syntax">Syntax</h2>
<pre class="eval">event.type
</pre>
<h2 name="Example">Examples</h2>
<pre><code><em>var string</em> = event.type;</code>
</pre>
<pre class="brush: html">&lt;html&gt;
&lt;head&gt;

&lt;title&gt;type example&lt;/title&gt;

&lt;script type="text/javascript"&gt;
var currEvent = null;

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

&lt;/script&gt;
&lt;/head&gt;

&lt;body
  onkeydown="getEvtType(event)"
  onkeyup="getEvtType(event)"
  onmousedown="getEvtType(event)"
  onmouseup="getEvtType(event)"&gt;

&lt;p&gt;Press any key or click the mouse to get the event type.&lt;/p&gt;
&lt;p&gt;Event type: &lt;span id="Etype"&gt;-&lt;/span&gt;&lt;/p&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
<h2 name="Specification">Specification</h2>
<p><a class="external" href="http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html#Events-Event-type">type </a></p>
<p>{{ languages( { "pl": "pl/DOM/event.type" } ) }}</p>
Revert to this revision