Event.type
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Sumário
Retorna uma string contendo o tipo de evento.
O argumento do evento EventTarget.addEventListener()
e EventTarget.removeEventListener()
é caso insensível(case insensitive).
Veja Mozilla event reference para obter a lista de tipos de evento disponíveis
Sintaxe
event.type
Exemplos
var string = event.type;
html
<!doctype html>
<html lang="pt-br">
<head>
<title>exemplo de tipo</title>
<script>
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>
Pressione uma tecla ou clique com o mouse para obter o tipo de evento.
</p>
<p>Tipo de evento: <span id="Etype">-</span></p>
</body>
</html>
Especificações
Specification |
---|
DOM # ref-for-dom-event-type④ |
Compatibilidade com navegadores
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
type |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.