-
Notifications
You must be signed in to change notification settings - Fork 602
Adding strafe and arrow control to keyboard telop #2028
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ const controlKeys = new Set([ | |
| " ", | ||
| "Shift", | ||
| "Control", | ||
| "Alt", | ||
| ]); | ||
|
|
||
| function isEditableTarget(target: EventTarget | null) { | ||
|
|
@@ -52,32 +53,40 @@ function calculateVelocities(keys: Set<string>) { | |
| return { linearX: 0, linearY: 0, angularY: 0, angularZ: 0 }; | ||
| } | ||
|
|
||
| // Linear X (forward/backward) - W/S | ||
| if (keys.has("w")) { | ||
| const forward = keys.has("w") || keys.has("ArrowUp"); | ||
| const backward = keys.has("s") || keys.has("ArrowDown"); | ||
|
|
||
| // Linear X (forward/backward) - W/S or ↑/↓ | ||
| if (forward && !backward) { | ||
| linearX = linearSpeed * speedMultiplier; | ||
| } else if (keys.has("s")) { | ||
| } else if (backward && !forward) { | ||
| linearX = -linearSpeed * speedMultiplier; | ||
| } | ||
|
|
||
| // Angular Z (yaw/turn) - A/D | ||
| if (keys.has("a")) { | ||
| angularZ = angularSpeed * speedMultiplier; | ||
| } else if (keys.has("d")) { | ||
| angularZ = -angularSpeed * speedMultiplier; | ||
| } | ||
|
|
||
| // Linear Y (strafe) - Left/Right arrows | ||
| if (keys.has("ArrowLeft")) { | ||
| linearY = linearSpeed * speedMultiplier; | ||
| } else if (keys.has("ArrowRight")) { | ||
| linearY = -linearSpeed * speedMultiplier; | ||
| } | ||
|
|
||
| // Angular Y (pitch) - Up/Down arrows | ||
| if (keys.has("ArrowUp")) { | ||
| angularY = angularSpeed * speedMultiplier; | ||
| } else if (keys.has("ArrowDown")) { | ||
| angularY = -angularSpeed * speedMultiplier; | ||
| const altStrafe = | ||
| keys.has("Alt") && | ||
| (keys.has("a") || | ||
| keys.has("d") || | ||
| keys.has("ArrowLeft") || | ||
| keys.has("ArrowRight")); | ||
|
|
||
| // Alt + A/D or ←/→: strafe (linear Y). Otherwise those keys turn (yaw). | ||
| if (altStrafe) { | ||
| const strafeLeft = keys.has("a") || keys.has("ArrowLeft"); | ||
| const strafeRight = keys.has("d") || keys.has("ArrowRight"); | ||
| if (strafeLeft && !strafeRight) { | ||
| linearY = linearSpeed * speedMultiplier; | ||
| } else if (strafeRight && !strafeLeft) { | ||
| linearY = -linearSpeed * speedMultiplier; | ||
| } | ||
| } else { | ||
| const turnLeft = keys.has("a") || keys.has("ArrowLeft"); | ||
| const turnRight = keys.has("d") || keys.has("ArrowRight"); | ||
| if (turnLeft && !turnRight) { | ||
| angularZ = angularSpeed * speedMultiplier; | ||
| } else if (turnRight && !turnLeft) { | ||
| angularZ = -angularSpeed * speedMultiplier; | ||
| } | ||
| } | ||
|
Comment on lines
+66
to
90
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
On macOS, holding Alt and pressing A generates |
||
|
|
||
| return { linearX, linearY, angularY, angularZ }; | ||
|
|
@@ -182,8 +191,8 @@ export default function KeyboardControlPanel({ | |
| {isActive && ( | ||
| <div style={{ marginTop: 10, fontSize: 12, color: "#666" }}> | ||
| <div>Controls:</div> | ||
| <div>W/S: Forward/Backward | A/D: Turn</div> | ||
| <div>Arrows: Strafe/Pitch | Space: Stop</div> | ||
| <div>W/S or ↑/↓: Forward/Backward | A/D or ←/→: Turn</div> | ||
| <div>Alt+A/D or Alt+←/→: Strafe | Space: Stop</div> | ||
| <div>Shift: Boost | Ctrl: Slow</div> | ||
| </div> | ||
| )} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This control center extension is deprecated so no need to change it