Fix checkKey function conflict

Merge in changes accidentally reverted by modifications
This commit is contained in:
Adam Wisher
2024-02-08 21:11:20 +00:00
committed by GitHub
parent 9b9db240e6
commit d5fb93508a
+19 -9
View File
@@ -316,25 +316,35 @@ function getCurrentFreq() {
function checkKey(e) { function checkKey(e) {
e = e || window.event; e = e || window.event;
// Check if any input element is focused using jQuery
if ($('input:focus').length > 0) {
return; // Do nothing if an input is focused
}
getCurrentFreq(); getCurrentFreq();
if (socket.readyState === WebSocket.OPEN) { if (socket.readyState === WebSocket.OPEN) {
if (e.keyCode == '82') { // RDS Reset (R key) switch (e.keyCode) {
case 82: // RDS Reset (R key)
socket.send("T" + (currentFreq.toFixed(1) * 1000)); socket.send("T" + (currentFreq.toFixed(1) * 1000));
} break;
if (e.keyCode == '38') { case 38:
let smallStep = (currentFreq > 30) ? 10 : 1; let smallStep = (currentFreq > 30) ? 10 : 1;
socket.send("T" + (Math.round(currentFreq*1000) + smallStep)); socket.send("T" + (Math.round(currentFreq*1000) + smallStep));
} break;
else if (e.keyCode == '40') { case 40:
let smallStep = (currentFreq > 30) ? 10 : 1; let smallStep = (currentFreq > 30) ? 10 : 1;
socket.send("T" + (Math.round(currentFreq*1000) - smallStep)); socket.send("T" + (Math.round(currentFreq*1000) - smallStep));
} break;
else if (e.keyCode == '37') { case 37:
tuneDown(); tuneDown();
} break;
else if (e.keyCode == '39') { case 39:
tuneUp(); tuneUp();
break;
default:
// Handle default case if needed
break;
} }
} }
} }