mirror of
https://github.com/hanzoai/sentinel.git
synced 2026-09-29 22:34:33 +00:00
14 lines
480 B
TypeScript
14 lines
480 B
TypeScript
import {isAppleDevice, isMac} from '@react-aria/utils';
|
|
|
|
/**
|
|
* Whether a modifier key (ctrl/alt/shift) is being pressed. Based on
|
|
* https://github.com/adobe/react-spectrum/blob/main/packages/%40react-aria/selection/src/utils.ts
|
|
*/
|
|
export function isModifierKeyPressed(e: React.KeyboardEvent<HTMLDivElement>) {
|
|
return (
|
|
(isAppleDevice() ? e.altKey : e.ctrlKey) || // contiguous selection modifier
|
|
(isMac() ? e.metaKey : e.ctrlKey) || // ctrl key
|
|
e.shiftKey
|
|
);
|
|
}
|