Skip to content

Commit 687b948

Browse files
utkarsh22gargapollonian
authored andcommitted
Fixed issue #38 of space input
1 parent bb387f6 commit 687b948

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/lib/index.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const BACKSPACE = 8;
66
const LEFT_ARROW = 37;
77
const RIGHT_ARROW = 39;
88
const DELETE = 46;
9+
const SPACEBAR = 32;
910

1011
type Props = {
1112
numInputs: number,
@@ -198,7 +199,7 @@ class OtpInput extends Component<Props, State> {
198199
this.focusNextInput();
199200
};
200201

201-
// Handle cases of backspace, delete, left arrow, right arrow
202+
// Handle cases of backspace, delete, left arrow, right arrow, space
202203
handleOnKeyDown = (e: Object) => {
203204
if (e.keyCode === BACKSPACE || e.key === 'Backspace') {
204205
e.preventDefault();
@@ -213,6 +214,8 @@ class OtpInput extends Component<Props, State> {
213214
} else if (e.keyCode === RIGHT_ARROW || e.key === 'ArrowRight') {
214215
e.preventDefault();
215216
this.focusNextInput();
217+
} else if (e.keyCode === SPACEBAR || e.key === 'Space' ) {
218+
e.preventDefault();
216219
}
217220
};
218221

0 commit comments

Comments
 (0)