Open In App

HTML DOM type Event Property

Last Updated : 15 Jun, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

The type event property in HTML DOM is used to return the type of the triggered event. It returns a string that represents the type of the event. The events can be keyboard events or mouse events. 

Syntax:

event.type

Return Value: It returns a string that represents the type of event. 

Example: In this example, we will use DOM type Event Property

HTML




<!DOCTYPE html>
<html>
   
<head>
    <title>
        HTML DOM type Event Property
    </title>
</head>
   
<body onmousedown="event_name(event)"
      onmouseup="event_name(event)"
      onkeydown="event_name(event)"
      onkeyup="event_name(event)">
    <h1>GeeksforGeeks</h1>
    <h2>DOM type Event Property</h2>
    <p>
        press any key or click the mouse
        to get event name.
    </p>
    <p>Triggered Event: <span id="GFG"></span></p>
    <!-- script to display event name -->
   
    <script>
        function event_name(event) {
            let e = event.type;
            document.getElementById("GFG").innerHTML = e;
        }
    </script>
</body>
   
</html>


Output: 

 

Supported Browsers: The browsers supported by DOM type event property are listed below:

  • Opera
  • Internet Explorer 9.0
  • Google Chrome
  • Firefox
  • Apple Safari

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads