From 6438d1a78143983fd515a082aa3c2f3ff07d97cc Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Sat, 2 Jul 2022 14:22:10 +0300 Subject: [PATCH] Vote with S/K keys instead of < > keys --- app/modules/plus-server/usePlusVoting.ts | 12 +++++------- app/routes/plus/voting/index.tsx | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/modules/plus-server/usePlusVoting.ts b/app/modules/plus-server/usePlusVoting.ts index 1d2e50f85..69cbf128a 100644 --- a/app/modules/plus-server/usePlusVoting.ts +++ b/app/modules/plus-server/usePlusVoting.ts @@ -55,7 +55,7 @@ export function usePlusVoting(usersForVotingFromServer: UsersForVoting) { setVotes, }); - useVoteWithArrowKeysEffect(addVote); + useVoteWithKeysEffect(addVote); const currentUser = usersForVoting?.[votes.length]; @@ -133,15 +133,13 @@ function useLoadInitialStateFromLocalStorageEffect({ }, [month, year, usersForVotingFromServer, setUsersForVoting, setVotes]); } -function useVoteWithArrowKeysEffect( - vote: (type: "upvote" | "downvote") => void -) { +function useVoteWithKeysEffect(vote: (type: "upvote" | "downvote") => void) { React.useEffect(() => { const handleKeyDown = (e: KeyboardEvent) => { - if (e.code === "ArrowRight") { - vote("upvote"); - } else if (e.code === "ArrowLeft") { + if (e.code === "KeyS") { vote("downvote"); + } else if (e.code === "KeyK") { + vote("upvote"); } }; diff --git a/app/routes/plus/voting/index.tsx b/app/routes/plus/voting/index.tsx index 004f81ce5..ba2b023d9 100644 --- a/app/routes/plus/voting/index.tsx +++ b/app/routes/plus/voting/index.tsx @@ -199,7 +199,7 @@ function VotingTimingInfo( const tips = [ "Voting progress is saved locally", - "Use left and right arrows on desktop to vote", + "Use S (-1) and K (+1) arrows on desktop to vote", "You +1 yourself automatically", ];