rpikvm/templates/keyboard.html

75 lines
1.4 KiB
HTML
Raw Normal View History

2020-06-05 17:16:52 +02:00
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Klávesnice remote SSH</title>
<style>
</style>
<script src="https://code.jquery.com/jquery-3.5.0.js"></script>
2020-06-07 14:24:15 +02:00
<script src="//cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js" integrity="sha256-yr4fRk/GU1ehYJPAs8P4JlTgu0Hdsp4ZKrx8bDEDC3I=" crossorigin="anonymous"></script>
2020-06-05 17:16:52 +02:00
</head>
<body>
HID input keyboard, POST data to /keyboard<br/>
2020-06-05 17:16:52 +02:00
<div>
</div>
<br/>
Server response: <span></span>
<script>
2020-06-07 14:24:15 +02:00
var socket = io();
2020-06-05 17:16:52 +02:00
function zapis(t) {
$("div").text(t);
}
var previous;
$(window).bind('keydown', function(event) {
event.preventDefault();
var str = String.fromCharCode(event.which).toLowerCase();
var ctrl = event.ctrlKey;
if (previous == 17) {
ctrl = true;
}
var obj = {
ctrlKey: ctrl,
shiftKey: event.shiftKey,
altKey: event.altKey,
which: event.which,
2020-06-07 14:24:15 +02:00
code: event.code,
2020-06-05 17:16:52 +02:00
str: str
}
if (event.which != 16 && event.which != 17 && event.which != 18) {
console.log(obj);
2020-06-07 14:24:15 +02:00
socket.emit('kbdEvent', JSON.stringify(obj));
2020-06-05 17:16:52 +02:00
}
var text = "";
if (ctrl) {
text = text + ' + Control';
}
if (event.shiftKey) {
text = text + ' + Shift';
}
if (event.altKey) {
text = text + ' + Alt';
}
text = text + ' + ' + str;
text = text.substr(3);
zapis(text);
previous = event.keyCode;
});
</script>
</body>
</html>