Spaces:
Runtime error
Runtime error
da03
commited on
Commit
·
4bedca7
1
Parent(s):
5850e24
- static/index.html +6 -4
static/index.html
CHANGED
|
@@ -758,11 +758,12 @@
|
|
| 758 |
}
|
| 759 |
|
| 760 |
document.addEventListener("keydown", function (event) {
|
| 761 |
-
if
|
|
|
|
| 762 |
event.preventDefault();
|
| 763 |
event.stopPropagation();
|
| 764 |
}
|
| 765 |
-
if (!isConnected || isProcessing) return;
|
| 766 |
|
| 767 |
// Get the current mouse position
|
| 768 |
let rect = canvas.getBoundingClientRect();
|
|
@@ -773,11 +774,12 @@
|
|
| 773 |
});
|
| 774 |
|
| 775 |
document.addEventListener("keyup", function (event) {
|
| 776 |
-
if
|
|
|
|
| 777 |
event.preventDefault();
|
| 778 |
event.stopPropagation();
|
| 779 |
}
|
| 780 |
-
if (!isConnected || socket.readyState !== WebSocket.OPEN) return;
|
| 781 |
|
| 782 |
// Get the current mouse position
|
| 783 |
let rect = canvas.getBoundingClientRect();
|
|
|
|
| 758 |
}
|
| 759 |
|
| 760 |
document.addEventListener("keydown", function (event) {
|
| 761 |
+
// Only prevent default if user has interacted with the canvas
|
| 762 |
+
if (userHasInteracted && (TROUBLESOME.has(event.key) || isForbiddenCombo(event))) {
|
| 763 |
event.preventDefault();
|
| 764 |
event.stopPropagation();
|
| 765 |
}
|
| 766 |
+
if (!isConnected || isProcessing || !userHasInteracted) return;
|
| 767 |
|
| 768 |
// Get the current mouse position
|
| 769 |
let rect = canvas.getBoundingClientRect();
|
|
|
|
| 774 |
});
|
| 775 |
|
| 776 |
document.addEventListener("keyup", function (event) {
|
| 777 |
+
// Only prevent default if user has interacted with the canvas
|
| 778 |
+
if (userHasInteracted && TROUBLESOME.has(event.key)) {
|
| 779 |
event.preventDefault();
|
| 780 |
event.stopPropagation();
|
| 781 |
}
|
| 782 |
+
if (!isConnected || socket.readyState !== WebSocket.OPEN || !userHasInteracted) return;
|
| 783 |
|
| 784 |
// Get the current mouse position
|
| 785 |
let rect = canvas.getBoundingClientRect();
|