Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 38x 5x 5x 5x 33x | import {TYPES} from '../config.js' export default (event, {type, onEnterKey}) => { if (type === TYPES.NUMBER) { // Check if input type number is valid as input type number doesn't currently work in browsers like Safari and Firefox // Allowing: Integers | Backspace | Tab | Delete | Left & Right arrow keys // const allowedCharacter = // /(^\d*$)|(Backspace|Tab|Delete|ArrowLeft|ArrowRight|Enter)/ const onEnterKeyArray = Array.isArray(onEnterKey) ? onEnterKey : [onEnterKey] const allowedCharacter = new RegExp( `(^\\d*$)|(${['Backspace', 'Tab', 'Delete', 'ArrowLeft', 'ArrowRight', ...onEnterKeyArray].join('|')})` ) return event.key.match(allowedCharacter) } return true } |