Files
noVNC/tests/input.html
Joel Martin d3796c149e API change: Mouse/kbd handling to include/input.js
API change: for intergrators that explicitly include the Javascript
files (that do not use include/vnc.js)js, include/input.js is a new
file that must also be included.

The mouse and keyboard handling could be useful on its own so split it
out into a Keyboard and Mouse class in include/input.js.

This refactoring is preparation to deal with issue #21 - non-US
keyboard layouts.
2011-04-03 17:30:45 -05:00

71 lines
2.2 KiB
HTML

<!DOCTYPE html>
<html>
<head><title>Input Test</title></head>
<body>
<br><br>
Canvas:<br>
<canvas id="canvas" width="640" height="20"
style="border-style: dotted; border-width: 1px;">
Canvas not supported.
</canvas>
<br>
Results:<br>
<textarea id="messages" style="font-size: 9;" cols=80 rows=25></textarea>
</body>
<!--
<script type='text/javascript'
src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
-->
<script src="../include/util.js"></script>
<script src="../include/webutil.js"></script>
<script src="../include/base64.js"></script>
<script src="../include/input.js"></script>
<script src="../include/canvas.js"></script>
<script>
var msg_cnt = 0;
var width = 400, height = 200;
var iterations;
function message(str) {
console.log(str);
cell = $D('messages');
cell.innerHTML += msg_cnt + ": " + str + "\n";
cell.scrollTop = cell.scrollHeight;
}
function mouseButton(x, y, down, bmask) {
msg = 'mouse x,y: ' + x + ',' + y + ' down: ' + down;
msg += ' bmask: ' + bmask;
console.log(msg);
message(msg);
}
function mouseMove(x, y) {
msg = 'mouse x,y: ' + x + ',' + y;
//console.log(msg);
}
function keyPress(keysym, down) {
msg = "keyPress keysym: " + keysym + " down: " + down;
console.log(msg);
message(msg);
}
window.onload = function() {
var canvas = new Canvas({'target' : $D('canvas')});
keyboard = new Keyboard({'target': document,
'keyPress': keyPress});
mouse = new Mouse({'target': $D('canvas'),
'mouseButton': mouseButton,
'mouseMove': mouseMove});
canvas.resize(width, height, true);
keyboard.grab();
mouse.grab();
message("Canvas initialized");
}
</script>
</html>