Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

이 문서는 아직 자원 봉사자들이 한국어로 번역하지 않았습니다. 함께 해서 번역을 마치도록 도와 주세요!

The Event.type read-only property returns a string containing the type of event. It is set when the event is constructed and is the name commonly used to refer to the specific event.

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

For a list of available event types, see the event reference

Syntax

event.type

Examples

var string = event.type;
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">

    <title>Event.type Example</title>

    <script>
        var currEvent = null;

        function getEvtType(evt) {
            console.log("//Start------------getEvtType(evt)------------ ");

            currEvent = evt.type;
            console.log(currEvent);

            //document.getElementById("Etype").firstChild.nodeValue = currEvent;
            document.getElementById("Etype").innerHTML = currEvent;

            console.log("//End--------------getEvtType(evt)------------ ");
        }

        //Keyboard events
        document.addEventListener("keypress", getEvtType, false); //[second]  

        document.addEventListener("keydown", getEvtType, false); //first
        document.addEventListener("keyup", getEvtType, false); //third

        //Mouse events
        document.addEventListener("click", getEvtType, false); // third

        document.addEventListener("mousedown", getEvtType, false); //first
        document.addEventListener("mouseup", getEvtType, false); //second

    </script>
</head>

<body>

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

</body>
</html>

Specifications

Specification Status Comment
DOM
The definition of 'Event.type' in that specification.
Living Standard  
DOM4
The definition of 'Event.type' in that specification.
Working Draft  
Document Object Model (DOM) Level 2 Events Specification
The definition of 'Event.type' in that specification.
Recommendation Initial definition.

문서 태그 및 공헌자

 최종 변경: cvrebert,