UNPKG

@fluentui/react-northstar

Version:
16 lines (15 loc) 725 B
import { getCode, SpacebarKey, EnterKey } from '@fluentui/accessibility'; /** * Checks if `preventDefault()` should be called for a passed keyboard event. */ export function shouldPreventDefaultOnKeyDown(e) { var code = getCode(e); var target = e.target; var matchesByKey = code === SpacebarKey || code === EnterKey; if ((target == null ? void 0 : target.tagName) === 'A') { return code === SpacebarKey; } var ignoredByTag = (target == null ? void 0 : target.tagName) === 'INPUT' || (target == null ? void 0 : target.tagName) === 'TEXTAREA' || (target == null ? void 0 : target.isContentEditable) === true; return matchesByKey && !ignoredByTag; } //# sourceMappingURL=shouldPreventDefaultOnKeyDown.js.map