HTML | DOM type Event Property

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

Syntax:

event.type

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

Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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) {
                var e = event.type;
                document.getElementById("GFG").innerHTML = e;
            }
        </script>
    </body>
</html>                    

chevron_right


Output:
Before Click on the button:

After click on the button:

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

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


My Personal Notes arrow_drop_up

I am a technology enthusiast who has a keen interest in programming I am pursuing Engineering in Computer Science from GEU, Dehradun I like to unwind by watching movies and English sitcomsI have a keen interest in music

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.