( key: IndividualKey | (() => IndividualKey), )
| 44 | * ``` |
| 45 | */ |
| 46 | export function createKeyHold( |
| 47 | key: IndividualKey | (() => IndividualKey), |
| 48 | ): () => boolean { |
| 49 | const tracker = getKeyStateTracker() |
| 50 | const heldKeysSelector = useSelector(tracker.store, (state) => state.heldKeys) |
| 51 | |
| 52 | return createMemo(() => { |
| 53 | const resolvedKey = typeof key === 'function' ? key() : key |
| 54 | const normalizedKey = resolvedKey.toLowerCase() |
| 55 | return heldKeysSelector().some( |
| 56 | (heldKey) => heldKey.toLowerCase() === normalizedKey, |
| 57 | ) |
| 58 | }) |
| 59 | } |
no test coverage detected
searching dependent graphs…