Refactor input handlings slightly
This commit is contained in:
parent
f9435c3a21
commit
26fac96b14
1 changed files with 5 additions and 9 deletions
14
src/App.tsx
14
src/App.tsx
|
|
@ -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);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue