Skip to content

Commit a8814e7

Browse files
authored
Merge pull request #53 from hacknug/patch-1
Fix `handleOnKeyDown` preventing users from interacting using the keyboard
2 parents 0823daf + 20ab4af commit a8814e7

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/components/SingleOtpInput.vue

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,10 @@ export default {
8484
return this.$emit('on-change', this.model);
8585
},
8686
handleOnKeyDown(event) {
87-
// Only allow characters 0-9, DEL, Backspace and Pasting
87+
// Only allow characters 0-9, DEL, Backspace, Enter, Right and Left Arrows, and Pasting
8888
const keyEvent = (event) || window.event;
8989
const charCode = (keyEvent.which) ? keyEvent.which : keyEvent.keyCode;
90-
if (this.isCodeNumeric(charCode)
91-
|| (charCode === 8)
92-
|| (charCode === 86)
93-
|| (charCode === 46)) {
90+
if (this.isCodeNumeric(charCode) || [8, 9, 13, 37, 39, 46, 86].includes(charCode)) {
9491
this.$emit('on-keydown', event);
9592
} else {
9693
keyEvent.preventDefault();

0 commit comments

Comments
 (0)