KeyFilter

A keyfilter is a directive used to block individual keystrokes based on a pattern.


import KeyFilter from 'primevue/keyfilter';

app.directive('keyfilter', KeyFilter);

KeyFilter provides various presets configured with the v-keyfilter directive.


<InputText v-keyfilter.int />
<InputText v-keyfilter.num />
<InputText v-keyfilter.money />
<InputText v-keyfilter.hex />
<InputText v-keyfilter.alpha />
<InputText v-keyfilter.alphanum />

In addition to the presets, a regular expression can be configured for customization of blocking a single key press.


<InputText v-model="spacekey" v-keyfilter="/[^s]/" />
<InputText v-model="chars" v-keyfilter="/^[^<>*!]+$/" />

In addition to the presets, a regular expression can be used to validate the entire word using validateOnly option.


<InputText v-model="text" v-keyfilter="{ pattern: /^[+]?(d{1,12})?$/, validateOnly: true }" />

KeyFilter is a directive and do not require any accessibility features.