Add keyboard controls and finer tuning steps for frequency tuning

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Smittix
2026-01-21 10:19:40 +00:00
parent 1e59cfd2ea
commit 88418b0850
2 changed files with 55 additions and 3 deletions

View File

@@ -1542,6 +1542,44 @@ function initListeningPost() {
audioReconnectAttempts = 0;
});
}
// Keyboard controls for frequency tuning
document.addEventListener('keydown', function(e) {
// Only active in listening mode
if (typeof currentMode !== 'undefined' && currentMode !== 'listening') {
return;
}
// Don't intercept if user is typing in an input
const activeEl = document.activeElement;
if (activeEl && (activeEl.tagName === 'INPUT' || activeEl.tagName === 'TEXTAREA' || activeEl.tagName === 'SELECT')) {
return;
}
// Arrow keys for tuning
// Up/Down: fine tuning (Shift for ultra-fine)
// Left/Right: coarse tuning (Shift for very coarse)
let delta = 0;
switch (e.key) {
case 'ArrowUp':
delta = e.shiftKey ? 0.005 : 0.05;
break;
case 'ArrowDown':
delta = e.shiftKey ? -0.005 : -0.05;
break;
case 'ArrowRight':
delta = e.shiftKey ? 1 : 0.1;
break;
case 'ArrowLeft':
delta = e.shiftKey ? -1 : -0.1;
break;
default:
return; // Not a tuning key
}
e.preventDefault();
tuneFreq(delta);
});
}
// Initialize when DOM is ready
@@ -1940,8 +1978,10 @@ function tuneFreq(delta) {
const freqInput = document.getElementById('radioScanStart');
if (freqInput) {
let newFreq = parseFloat(freqInput.value) + delta;
// Round to 3 decimal places to avoid floating-point precision issues
newFreq = Math.round(newFreq * 1000) / 1000;
newFreq = Math.max(24, Math.min(1800, newFreq));
freqInput.value = newFreq.toFixed(1);
freqInput.value = newFreq.toFixed(3);
// Update display
const freqDisplay = document.getElementById('mainScannerFreq');

View File

@@ -1004,6 +1004,10 @@
style="padding: 8px 12px; font-size: 11px;">-1</button>
<button class="tune-btn" onclick="tuneFreq(-0.1)"
style="padding: 8px 12px; font-size: 11px;">-.1</button>
<button class="tune-btn" onclick="tuneFreq(-0.05)"
style="padding: 8px 12px; font-size: 11px;">-.05</button>
<button class="tune-btn" onclick="tuneFreq(-0.005)"
style="padding: 8px 12px; font-size: 10px;">-.005</button>
</div>
<!-- Main Tuning Dial -->
@@ -1013,14 +1017,22 @@
<div
style="font-size: 9px; color: var(--text-muted); margin-top: 6px; text-transform: uppercase; letter-spacing: 1px;">
Tune</div>
<div
style="font-size: 8px; color: var(--text-muted); margin-top: 3px; opacity: 0.6;"
title="Arrow keys: &#177;0.05/0.1 MHz&#10;Shift+Arrow: &#177;0.005/1 MHz">
&#9000; arrow keys</div>
</div>
<!-- Fine Tune Buttons (Right of dial) -->
<div style="display: flex; flex-direction: column; gap: 4px;">
<button class="tune-btn" onclick="tuneFreq(0.1)"
style="padding: 8px 12px; font-size: 11px;">+.1</button>
<button class="tune-btn" onclick="tuneFreq(1)"
style="padding: 8px 12px; font-size: 11px;">+1</button>
<button class="tune-btn" onclick="tuneFreq(0.1)"
style="padding: 8px 12px; font-size: 11px;">+.1</button>
<button class="tune-btn" onclick="tuneFreq(0.05)"
style="padding: 8px 12px; font-size: 11px;">+.05</button>
<button class="tune-btn" onclick="tuneFreq(0.005)"
style="padding: 8px 12px; font-size: 10px;">+.005</button>
</div>
<!-- Divider -->