Skip to content

Commit

Permalink
Merge pull request #9719 from davisb10/patch-2
Browse files Browse the repository at this point in the history
Fixed #9718 - Expose InputMask OnKeyDown event
  • Loading branch information
yigitfindikli authored Feb 17, 2021
2 parents ca46e09 + 3fa4768 commit b3578a7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/app/components/inputmask/inputmask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ export class InputMask implements OnInit,OnDestroy,ControlValueAccessor {
@Output() onBlur: EventEmitter<any> = new EventEmitter();

@Output() onInput: EventEmitter<any> = new EventEmitter();

@Output() onKeyDown: EventEmitter<any> = new EventEmitter();

value: any;

Expand Down Expand Up @@ -404,6 +406,8 @@ export class InputMask implements OnInit,OnDestroy,ControlValueAccessor {
end;
let iPhone = /iphone/i.test(DomHandler.getUserAgent());
this.oldVal = this.inputViewChild.nativeElement.value;

this.onKeyDown.emit(e);

//backspace, delete, and escape get special treatment
if (k === 8 || k === 46 || (iPhone && k === 127)) {
Expand Down
7 changes: 6 additions & 1 deletion src/app/showcase/components/inputmask/inputmaskdemo.html
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@ <h5>Events</h5>
<td>-</td>
<td>Callback to invoke on when the input field value is altered.</td>
</tr>
<tr>
<td>onKeyDown</td>
<td>event: KeyboardEvent</td>
<td>Callback to invoke on when the input receives a keydown event.</td>
</tr>
</tbody>
</table>
</div>
Expand Down Expand Up @@ -362,4 +367,4 @@ <h5>Dependencies</h5>
</ng-template>
</p-tabPanel>
</p-tabView>
</div>
</div>

0 comments on commit b3578a7

Please sign in to comment.