mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-04 14:11:02 +03:00
Merge pull request #7200 from MisoMosiSpy/input_example_keymodifiers
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 33 KiB |
BIN
tutorials/inputs/img/inputs_inputmap.webp
Normal file
BIN
tutorials/inputs/img/inputs_inputmap.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 41 KiB |
@@ -101,13 +101,18 @@ event scroll by in the output window. Here's an example of the output:
|
||||
::
|
||||
|
||||
A
|
||||
InputEventMouseMotion : button_mask=0, position=(108, 108), relative=(26, 1), speed=(164.152496, 159.119843), pressure=(0), tilt=(0, 0)
|
||||
InputEventMouseButton : button_index=MOUSE_BUTTON_LEFT, pressed=true, position=(108, 107), button_mask=1, doubleclick=false
|
||||
InputEventMouseButton : button_index=MOUSE_BUTTON_LEFT, pressed=false, position=(108, 107), button_mask=0, doubleclick=false
|
||||
S
|
||||
F
|
||||
Mouse motion at position ((971, 5)) with velocity ((0, 0))
|
||||
Right Mouse Button
|
||||
Mouse motion at position ((870, 243)) with velocity ((0.454937, -0.454937))
|
||||
Left Mouse Button
|
||||
Mouse Wheel Up
|
||||
A
|
||||
B
|
||||
Shift
|
||||
Alt+Shift
|
||||
Alt
|
||||
InputEventMouseMotion : button_mask=0, position=(108, 107), relative=(0, -1), speed=(164.152496, 159.119843), pressure=(0), tilt=(0, 0)
|
||||
Shift+T
|
||||
Mouse motion at position ((868, 242)) with velocity ((-2.134768, 2.134768))
|
||||
|
||||
As you can see, the results are very different for the different types of
|
||||
input. Key events are even printed as their key symbols. For example, let's
|
||||
@@ -150,11 +155,14 @@ InputMap
|
||||
The :ref:`InputMap <class_InputMap>` is the most flexible way to handle a
|
||||
variety of inputs. You use this by creating named input *actions*, to which
|
||||
you can assign any number of input events, such as keypresses or mouse clicks.
|
||||
A new Godot project includes a number of default actions already defined. To
|
||||
see them, and to add your own, open Project -> Project Settings and select
|
||||
To see them, and to add your own, open Project -> Project Settings and select
|
||||
the InputMap tab:
|
||||
|
||||
.. image:: img/inputs_inputmap.png
|
||||
.. image:: img/inputs_inputmap.webp
|
||||
|
||||
.. tip::
|
||||
A new Godot project includes a number of default actions already defined.
|
||||
To see them, turn on ``Show Built-in Actions`` in the InputMap dialog.
|
||||
|
||||
Capturing actions
|
||||
~~~~~~~~~~~~~~~~~
|
||||
@@ -240,7 +248,7 @@ different when it's :kbd:`Shift + T`:
|
||||
func _input(event):
|
||||
if event is InputEventKey and event.pressed:
|
||||
if event.keycode == KEY_T:
|
||||
if event.shift:
|
||||
if event.shift_pressed:
|
||||
print("Shift+T was pressed")
|
||||
else:
|
||||
print("T was pressed")
|
||||
@@ -254,7 +262,7 @@ different when it's :kbd:`Shift + T`:
|
||||
switch (keyEvent.Keycode)
|
||||
{
|
||||
case Key.T:
|
||||
GD.Print(keyEvent.Shift ? "Shift+T was pressed" : "T was pressed");
|
||||
GD.Print(keyEvent.ShiftPressed ? "Shift+T was pressed" : "T was pressed");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user