Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

lint-staged
npm run lint-staged
7 changes: 3 additions & 4 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as React from 'react';
import classNames from 'classnames';
import useMergedState from 'rc-util/lib/hooks/useMergedState';
import KeyCode from 'rc-util/lib/KeyCode';
import * as React from 'react';

export type SwitchChangeEventHandler = (
checked: boolean,
Expand Down Expand Up @@ -66,9 +65,9 @@ const Switch = React.forwardRef<HTMLButtonElement, SwitchProps>(
}

function onInternalKeyDown(e: React.KeyboardEvent<HTMLButtonElement>) {
if (e.which === KeyCode.LEFT) {
if (e.key === 'ArrowLeft') {
triggerChange(false, e);
} else if (e.which === KeyCode.RIGHT) {
} else if (e.key === 'ArrowRight') {
triggerChange(true, e);
}
onKeyDown?.(e);
Expand Down