forked from kbalog/web-programming
-
Notifications
You must be signed in to change notification settings - Fork 1
/
mouse_event_logger.html
41 lines (40 loc) · 1.15 KB
/
mouse_event_logger.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example: Mouse event logger</title>
<style>
div {
width: 600px;
height: 100px;
background-color: yellow;
border: 1px solid black;
}
textarea {
width: 600px;
border: 1px solid black;
}
</style>
<script>
function mhandle(event) {
var msg = event.type
+ " button=" + event.button
+ " clientCoord=(" + event.clientX + ", " + event.clientY + ")"
+ " screenCoord=(" + event.screenX + ", " + event.screenY + ")"
+ (event.shiftKey ? " +shift" : "")
+ (event.ctrlKey ? " +ctrl" : "")
+ (event.altKey ? " +alt" : "")
+ (event.metaKey ? " +meta" : "");
document.getElementById("log").innerHTML += msg + "\n";
}
</script>
</head>
<body>
Click within the yellow area;
<div onclick="mhandle(event);"></div>
<form name="mouseform">
Log:<br/>
<textarea rows="18" id="log"></textarea>
</form>
</body>
</html>