export function snapControls(value: number, event: string): number { const CTRL_DISTANCE = 1; // Snap to whole numbers when Ctrl is pressed const SHIFT_DISTANCE = 0.01; // Snap to half-step increments when Shift is pressed const CTRL_SHIFT_DISTANCE = 0.1; // Snap to fine increments when both Ctrl and Shift are pressed switch (event) { case "Ctrl": return Math.round(value / CTRL_DISTANCE) * CTRL_DISTANCE; case "Shift": return Math.round(value / SHIFT_DISTANCE) * SHIFT_DISTANCE; case "Ctrl+Shift": const base = Math.floor(value / CTRL_DISTANCE) * CTRL_DISTANCE; const offset = Math.round((value - base) / CTRL_SHIFT_DISTANCE) * CTRL_SHIFT_DISTANCE; return base + offset; default: return value; // No snapping if no modifier key is pressed } }