From 8155f16e59a938233afdede055ace10094892735 Mon Sep 17 00:00:00 2001 From: Peter Date: Wed, 25 Dec 2024 23:00:31 +0100 Subject: [PATCH 1/3] fix(KeyboardControls): support non-QWERTY keyboards --- src/core/controls/KeyboardControls.vue | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/controls/KeyboardControls.vue b/src/core/controls/KeyboardControls.vue index d927c7f84..ba06b502b 100644 --- a/src/core/controls/KeyboardControls.vue +++ b/src/core/controls/KeyboardControls.vue @@ -70,14 +70,14 @@ watch(props, () => { const sidewardMove = ref(0) const forwardMove = ref(0) -const { w, s, a, d, Up, Down, Left, Right } = useMagicKeys() +const { KeyW, KeyA, KeyS, KeyD, Up, Down, Left, Right } = useMagicKeys() watchEffect(() => { - if (a.value || Left.value) { sidewardMove.value = -moveSpeed.value } - else if (d.value || Right.value) { sidewardMove.value = moveSpeed.value } + if (KeyA.value || Left.value) { sidewardMove.value = -moveSpeed.value } + else if (KeyD.value || Right.value) { sidewardMove.value = moveSpeed.value } else { sidewardMove.value = 0 } - if (w.value || Up.value) { forwardMove.value = moveSpeed.value } - else if (s.value || Down.value) { forwardMove.value = -moveSpeed.value } + if (KeyW.value || Up.value) { forwardMove.value = moveSpeed.value } + else if (KeyS.value || Down.value) { forwardMove.value = -moveSpeed.value } else { forwardMove.value = 0 } }) From 1d410b357e5f6e842d8070e8e58234274ad16c82 Mon Sep 17 00:00:00 2001 From: Peter Date: Wed, 25 Dec 2024 23:04:14 +0100 Subject: [PATCH 2/3] docs(KeyboardControls): add mention of QWERTY/non-QWERTY layouts --- docs/guide/controls/keyboard-controls.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/guide/controls/keyboard-controls.md b/docs/guide/controls/keyboard-controls.md index ec8833385..ffd1d1c1d 100644 --- a/docs/guide/controls/keyboard-controls.md +++ b/docs/guide/controls/keyboard-controls.md @@ -1,11 +1,14 @@ # KeyboardControls -KeyboardControls is a special type of controller that allows you to move through the scene using your keyboard, is based on the Unreal Engine Controls. - +`` is a simple keyboard controller for the camera. The camera's movements are bound to: + +* WASD on QWERTY keyboards or equivalent keys on non-QWERTY keyboards +* Arrow keys + ::: info :memo: KeyboardControls uses `PointerLockControls` under the hood, meaning you can use [all the props from ``](pointer-lock-controls#props) as well as it events. ::: From 5306864b3f626d8750b280c079c9e6e9f2db266d Mon Sep 17 00:00:00 2001 From: Peter Date: Wed, 25 Dec 2024 23:05:18 +0100 Subject: [PATCH 3/3] docs(KeyboardControls): fix wording/formatting --- docs/guide/controls/keyboard-controls.md | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/docs/guide/controls/keyboard-controls.md b/docs/guide/controls/keyboard-controls.md index ffd1d1c1d..35c9c42a7 100644 --- a/docs/guide/controls/keyboard-controls.md +++ b/docs/guide/controls/keyboard-controls.md @@ -10,13 +10,11 @@ * Arrow keys ::: info -:memo: KeyboardControls uses `PointerLockControls` under the hood, meaning you can use [all the props from ``](pointer-lock-controls#props) as well as it events. +`` uses `` under the hood. You can use [`` props and events](pointer-lock-controls#props). ::: ## Usage -You can use the ASDW or the arrows keys to move and your mouse to explore your scene. - ```vue{3,10}