@quasar/quasar-ui-qcalendar
Version:
QCalendar - Day/Month/Week Calendars, Popups, Date Pickers, Schedules, Agendas, Planners and Tasks for your Vue Apps
24 lines (20 loc) • 728 B
text/typescript
/**
* Utility functions for event handling.
*/
interface EventUtilsReturn {
isKeyCode: (_evt: KeyboardEvent, _keyCodes: number | number[]) => boolean
}
export default function useEventUtils(): EventUtilsReturn {
/**
* Checks if the event's keyCode matches any of the specified keyCodes.
* @param {KeyboardEvent} evt - The keyboard event.
* @param {number | number[]} keyCodes - The key code or an array of key codes to check against.
* @returns {boolean} True if the keyCode matches, false otherwise.
*/
function isKeyCode(evt: KeyboardEvent, keyCodes: number | number[]): boolean {
return (Array.isArray(keyCodes) ? keyCodes : [keyCodes]).includes(evt.keyCode)
}
return {
isKeyCode,
}
}