MCPcopy Create free account
hub / github.com/adobe/react-spectrum / onKeyDown

Function onKeyDown

packages/react-aria/src/datepicker/useDateSegment.ts:128–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126 };
127
128 let onKeyDown = e => {
129 // Firefox does not fire selectstart for Ctrl/Cmd + A
130 // https://bugzilla.mozilla.org/show_bug.cgi?id=1742153
131 if (e.key === 'a' && (isMac() ? e.metaKey : e.ctrlKey)) {
132 e.preventDefault();
133 }
134
135 if (e.ctrlKey || e.metaKey || e.shiftKey || e.altKey) {
136 return;
137 }
138
139 switch (e.key) {
140 case 'Backspace':
141 case 'Delete': {
142 // Safari on iOS does not fire beforeinput for the backspace key because the cursor is at the start.
143 e.preventDefault();
144 e.stopPropagation();
145 backspace();
146 break;
147 }
148 }
149 };
150
151 // Safari dayPeriod option doesn't work...
152 let {startsWith} = useFilter({sensitivity: 'base'});

Callers

nothing calls this directly

Calls 1

backspaceFunction · 0.85

Tested by

no test coverage detected