mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-08-24 03:55:49 -05:00
Vote with S/K keys instead of < > keys
This commit is contained in:
@@ -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");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -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",
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user