Refactor input handlings slightly

This commit is contained in:
Chandler Swift 2026-02-11 20:41:29 -06:00
parent f9435c3a21
commit 26fac96b14
Signed by: chandlerswift
GPG key ID: A851D929D52FB93F

View file

@ -99,16 +99,12 @@ function App() {
// Handle keyboard/scanner input // Handle keyboard/scanner input
useEffect(() => { useEffect(() => {
const handleKeyDown = (ev: KeyboardEvent) => { const handleKeyDown = (ev: KeyboardEvent) => {
if (ev.key === "s") { // TODO: remove ev.preventDefault();
ev.preventDefault(); if (ev.key === "F1") { // TODO: remove
lookupBarcode("075021370814"); lookupBarcode("075021370814"); // Breakfast in America; owned
return; } else if (ev.key === "F2") {
} else if (ev.key === "d") { lookupBarcode("015775150522"); // Crime of the Century; not owned
ev.preventDefault();
lookupBarcode("015775150522");
return
} else if (ev.key === "Enter") { } else if (ev.key === "Enter") {
ev.preventDefault();
const code = buffer.join("").trim(); const code = buffer.join("").trim();
setBuffer([]); // Reset the buffer setBuffer([]); // Reset the buffer
lookupBarcode(code); lookupBarcode(code);