Skip to content
Snippets Groups Projects
Verified Commit 8db0c668 authored by João Magalhães's avatar João Magalhães :rocket:
Browse files

feat: mobile keyboard support

parent bedbd151
No related branches found
No related tags found
No related merge requests found
Pipeline #733 passed
...@@ -547,6 +547,18 @@ p { ...@@ -547,6 +547,18 @@ p {
.keyboard { .keyboard {
font-size: 0px; font-size: 0px;
text-align: center; text-align: center;
touch-callout: none;
-o-touch-callout: none;
-ms-touch-callout: none;
-moz-touch-callout: none;
-khtml-touch-callout: none;
-webkit-touch-callout: none;
user-select: none;
-o-user-select: none;
-ms-user-select: none;
-moz-user-select: none;
-khtml-user-select: none;
-webkit-user-select: none;
} }
.keyboard > .keyboard-line { .keyboard > .keyboard-line {
...@@ -572,12 +584,6 @@ p { ...@@ -572,12 +584,6 @@ p {
line-height: 46px; line-height: 46px;
margin-right: 14px; margin-right: 14px;
text-align: center; text-align: center;
user-select: none;
-o-user-select: none;
-ms-user-select: none;
-moz-user-select: none;
-khtml-user-select: none;
-webkit-user-select: none;
width: 48px; width: 48px;
} }
......
...@@ -150,4 +150,4 @@ ...@@ -150,4 +150,4 @@
<script type="module" src="index.ts"></script> <script type="module" src="index.ts"></script>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -493,11 +493,29 @@ const registerKeyboard = () => { ...@@ -493,11 +493,29 @@ const registerKeyboard = () => {
k.addEventListener("mousedown", function () { k.addEventListener("mousedown", function () {
const keyCode = KEYS[this.textContent.toLowerCase()]; const keyCode = KEYS[this.textContent.toLowerCase()];
state.chip8.key_press_ws(keyCode); state.chip8.key_press_ws(keyCode);
event.preventDefault();
event.stopPropagation();
});
k.addEventListener("touchstart", function (event) {
const keyCode = KEYS[this.textContent.toLowerCase()];
state.chip8.key_press_ws(keyCode);
event.preventDefault();
event.stopPropagation();
}); });
k.addEventListener("mouseup", function () { k.addEventListener("mouseup", function () {
const keyCode = KEYS[this.textContent.toLowerCase()]; const keyCode = KEYS[this.textContent.toLowerCase()];
state.chip8.key_lift_ws(keyCode); state.chip8.key_lift_ws(keyCode);
event.preventDefault();
event.stopPropagation();
});
k.addEventListener("touchend", function () {
const keyCode = KEYS[this.textContent.toLowerCase()];
state.chip8.key_lift_ws(keyCode);
event.preventDefault();
event.stopPropagation();
}); });
}); });
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment