refactor: Implement modifier key detection for keyboard shortcuts in various controls
This commit is contained in:
@@ -5,6 +5,7 @@ import { useCamMode, useToggleView } from '../../../store/store';
|
||||
import { useKeyboardControls } from '@react-three/drei';
|
||||
import switchToThirdPerson from './switchToThirdPerson';
|
||||
import switchToFirstPerson from './switchToFirstPerson';
|
||||
import { detectModifierKeys } from '../../../utils/shortcutkeys/detectModifierKeys';
|
||||
|
||||
const CamMode: React.FC = () => {
|
||||
const { camMode, setCamMode } = useCamMode();
|
||||
@@ -37,7 +38,9 @@ const CamMode: React.FC = () => {
|
||||
const handleKeyPress = async (event: any) => {
|
||||
if (!state.controls) return;
|
||||
|
||||
if (event.key === "/" && !isTransitioning && !toggleView) {
|
||||
const keyCombination = detectModifierKeys(event);
|
||||
|
||||
if (keyCombination === "/" && !isTransitioning && !toggleView) {
|
||||
setIsTransitioning(true);
|
||||
state.controls.mouseButtons.left = CONSTANTS.controlsTransition.leftMouse;
|
||||
state.controls.mouseButtons.right = CONSTANTS.controlsTransition.rightMouse;
|
||||
@@ -81,9 +84,7 @@ const CamMode: React.FC = () => {
|
||||
}
|
||||
});
|
||||
|
||||
return (
|
||||
<></>
|
||||
);
|
||||
return null; // This component does not render any UI
|
||||
};
|
||||
|
||||
export default CamMode;
|
||||
Reference in New Issue
Block a user