From 6df878b6e4bfb01154a7803329f188fe8dd408d3 Mon Sep 17 00:00:00 2001 From: iower Date: Fri, 6 Oct 2023 16:18:45 +0500 Subject: [PATCH] Swap hotkey --- src/ui/views/Dashboard/index.tsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/ui/views/Dashboard/index.tsx b/src/ui/views/Dashboard/index.tsx index 1968820d169..46a5a2c289a 100644 --- a/src/ui/views/Dashboard/index.tsx +++ b/src/ui/views/Dashboard/index.tsx @@ -375,6 +375,21 @@ const Dashboard = () => { history.push('/dex-swap'); }; + // ctrl+s => open swap + const onKeyDown = (e) => { + if (e.ctrlKey && e.key === 's') { + e.preventDefault(); + onClickSwap(); + } + }; + + useEffect(() => { + document.addEventListener('keydown', onKeyDown); + return () => { + document.removeEventListener('keydown', onKeyDown); + }; + }, []); + const brandIcon = useWalletConnectIcon(currentAccount); const { t } = useTranslation();