Skip to content

Commit b671bdb

Browse files
authored
Merge pull request #135 from code-farmz/fixes
#131
2 parents f0c728d + 4cec872 commit b671bdb

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

projects/ng-otp-input/src/lib/components/ng-otp-input/ng-otp-input.component.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,15 @@ export class NgOtpInputComponent implements OnInit, AfterViewInit, OnDestroy, Co
142142
onKeyDown($event, inputIdx) {
143143
const prevInputId = this.getBoxId(inputIdx - 1);
144144
const currentInputId = this.getBoxId(inputIdx);
145-
const nextInputId = this.getBoxId(inputIdx + 1);
145+
if (KeyboardUtil.ifKey($event, 'Enter')) {
146+
let inp = this.document.getElementById(currentInputId);
147+
const form = inp?.closest('form');
148+
if (form) {
149+
$event.preventDefault();
150+
form.dispatchEvent(new Event('submit'));
151+
return;
152+
}
153+
}
146154
if (KeyboardUtil.ifSpacebar($event)) {
147155
$event.preventDefault();
148156
return false;

0 commit comments

Comments
 (0)