HTML DOM 마우스 이벤트
MouseEvent 객체
마우스가 HTML 문서와 상호 작용할 때 발생하는 이벤트는 MouseEvent 객체에 속합니다.
MouseEvent 속성 및 메서드
Property/Method | Description |
---|---|
altKey | Returns whether the "ALT" key was pressed when the mouse event was triggered |
button | Returns which mouse button was pressed when the mouse event was triggered |
buttons | Returns which mouse buttons were pressed when the mouse event was triggered |
clientX | Returns the horizontal coordinate of the mouse pointer, relative to the current window, when the mouse event was triggered |
clientY | Returns the vertical coordinate of the mouse pointer, relative to the current window, when the mouse event was triggered |
ctrlKey | Returns whether the "CTRL" key was pressed when the mouse event was triggered |
getModifierState() | Returns true if the specified key is activated |
metaKey | Returns whether the "META" key was pressed when an event was triggered |
movementX | Returns the horizontal coordinate of the mouse pointer relative to the position of the last mousemove event |
movementY | Returns the vertical coordinate of the mouse pointer relative to the position of the last mousemove event |
offsetX | Returns the horizontal coordinate of the mouse pointer relative to the position of the edge of the target element |
offsetY | Returns the vertical coordinate of the mouse pointer relative to the position of the edge of the target element |
pageX | Returns the horizontal coordinate of the mouse pointer, relative to the document, when the mouse event was triggered |
pageY | Returns the vertical coordinate of the mouse pointer, relative to the document, when the mouse event was triggered |
region | |
relatedTarget | Returns the element related to the element that triggered the mouse event |
screenX | Returns the horizontal coordinate of the mouse pointer, relative to the screen, when an event was triggered |
screenY | Returns the vertical coordinate of the mouse pointer, relative to the screen, when an event was triggered |
shiftKey | Returns whether the "SHIFT" key was pressed when an event was triggered |
which | Returns which mouse button was pressed when the mouse event was triggered |
상속된 속성 및 메서드
MouseEvent는 다음에서 모든 속성과 메서드를 상속합니다.
이벤트 유형
다음 이벤트 유형은 MouseEvent 개체에 속합니다.
Event | Description |
---|---|
onclick | The event occurs when the user clicks on an element |
oncontextmenu | The event occurs when the user right-clicks on an element to open a context menu |
ondblclick | The event occurs when the user double-clicks on an element |
onmousedown | The event occurs when the user presses a mouse button over an element |
onmouseenter | The event occurs when the pointer is moved onto an element |
onmouseleave | The event occurs when the pointer is moved out of an element |
onmousemove | The event occurs when the pointer is moving while it is over an element |
onmouseout | The event occurs when a user moves the mouse pointer out of an element, or out of one of its children |
onmouseover | The event occurs when the pointer is moved onto an element, or onto one of its children |
onmouseup | The event occurs when a user releases a mouse button over an element |