MCPcopy Create free account
hub / github.com/AmazingAng/PolyWorld / handleFormKey

Function handleFormKey

src/components/OrderForm.tsx:832–845  ·  view source on GitHub ↗
(e: React.KeyboardEvent)

Source from the content-addressed store, hash-verified

830
831 // Must be defined before any conditional return to satisfy Rules of Hooks
832 const handleFormKey = (e: React.KeyboardEvent) => {
833 const tag = (e.target as HTMLElement).tagName;
834 if (tag === "INPUT") return;
835 if (e.key === "b" || e.key === "B") { e.preventDefault(); setSide("BUY"); }
836 if (e.key === "s" || e.key === "S") { e.preventDefault(); setSide("SELL"); }
837 if (e.key === "m" || e.key === "M") { e.preventDefault(); setLimitOnly(v => !v); }
838 if (e.key === "1") { e.preventDefault(); setAmount("5"); }
839 if (e.key === "2") { e.preventDefault(); setAmount("20"); }
840 if (e.key === "3") { e.preventDefault(); setAmount("50"); }
841 if (e.key === "4") { e.preventDefault(); setAmount("100"); }
842 if (e.key === "Enter" && !busy && amountNum > 0 && (isMarketOrder || priceNum > 0) && !sizeTooSmall) {
843 e.preventDefault(); handlePlaceOrder(undefined, undefined, isMarketOrder);
844 }
845 };
846
847 if (!isConnected) {
848 return (

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected