開発環境 |
メモ帳 |
実行環境 |
Microsoft Edge |
mouse1.html
<!doctype html>
<head>
<title>mouse1</title>
</head>
<body>
<canvas id="canvas" width="640" height="480"></canvas>
<div id="msg"></div>
<script>
onload = function() {
var ctx = canvas.getContext("2d");
ctx.fillStyle = "#6495ed";
ctx.fillRect(0, 0, canvas.width, canvas.height);
var drag = false;
canvas.onmousedown = function(e) {
drag = true;
};
canvas.onmouseup = function(e) {
drag = false;
};
canvas.onmousemove = function(e) {
msg.innerHTML = "x=" + e.clientX + " y=" + e.clientY + " drag=" + drag;
};
canvas.onmousewheel = function(e) {
msg.innerHTML = e.type + " " + e.wheelDelta;
};
};
</script>
</body>
最終更新:2016年02月14日 21:25