|
@@ -132,7 +132,7 @@ avoid this, make sure to test the event type first:
|
|
{
|
|
{
|
|
if (inputEvent is InputEventMouseButton mouseEvent)
|
|
if (inputEvent is InputEventMouseButton mouseEvent)
|
|
{
|
|
{
|
|
- GD.Print($"mouse button event at {mouseEvent.Position}");
|
|
|
|
|
|
+ GD.Print("mouse button event at ", mouseEvent.Position);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -185,7 +185,7 @@ the :kbd:`T`:
|
|
|
|
|
|
func _input(event):
|
|
func _input(event):
|
|
if event is InputEventKey and event.pressed:
|
|
if event is InputEventKey and event.pressed:
|
|
- if event.scancode == KEY_T:
|
|
|
|
|
|
+ if event.keycode == KEY_T:
|
|
print("T was pressed")
|
|
print("T was pressed")
|
|
|
|
|
|
.. code-tab:: csharp
|
|
.. code-tab:: csharp
|
|
@@ -194,14 +194,14 @@ the :kbd:`T`:
|
|
{
|
|
{
|
|
if (inputEvent is InputEventKey keyEvent && keyEvent.Pressed)
|
|
if (inputEvent is InputEventKey keyEvent && keyEvent.Pressed)
|
|
{
|
|
{
|
|
- if ((Keylist)keyEvent.Scancode == KeyList.T)
|
|
|
|
|
|
+ if ((Keylist)keyEvent.Keycode == KeyList.T)
|
|
{
|
|
{
|
|
GD.Print("T was pressed");
|
|
GD.Print("T was pressed");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-.. tip:: See :ref:`@GlobalScope_KeyList <enum_@GlobalScope_KeyList>` for a list of scancode
|
|
|
|
|
|
+.. tip:: See :ref:`@GlobalScope_KeyList <enum_@GlobalScope_KeyList>` for a list of keycode
|
|
constants.
|
|
constants.
|
|
|
|
|
|
Keyboard modifiers
|
|
Keyboard modifiers
|
|
@@ -218,7 +218,7 @@ different when it's :kbd:`Shift + T`:
|
|
|
|
|
|
func _input(event):
|
|
func _input(event):
|
|
if event is InputEventKey and event.pressed:
|
|
if event is InputEventKey and event.pressed:
|
|
- if event.scancode == KEY_T:
|
|
|
|
|
|
+ if event.keycode == KEY_T:
|
|
if event.shift:
|
|
if event.shift:
|
|
print("Shift+T was pressed")
|
|
print("Shift+T was pressed")
|
|
else:
|
|
else:
|
|
@@ -230,7 +230,7 @@ different when it's :kbd:`Shift + T`:
|
|
{
|
|
{
|
|
if (inputEvent is InputEventKey keyEvent && keyEvent.Pressed)
|
|
if (inputEvent is InputEventKey keyEvent && keyEvent.Pressed)
|
|
{
|
|
{
|
|
- switch ((KeyList)keyEvent.Scancode)
|
|
|
|
|
|
+ switch ((KeyList)keyEvent.Keycode)
|
|
{
|
|
{
|
|
case KeyList.T:
|
|
case KeyList.T:
|
|
GD.Print(keyEvent.Shift ? "Shift+T was pressed" : "T was pressed");
|
|
GD.Print(keyEvent.Shift ? "Shift+T was pressed" : "T was pressed");
|
|
@@ -239,7 +239,7 @@ different when it's :kbd:`Shift + T`:
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-.. tip:: See :ref:`@GlobalScope_KeyList <enum_@GlobalScope_KeyList>` for a list of scancode
|
|
|
|
|
|
+.. tip:: See :ref:`@GlobalScope_KeyList <enum_@GlobalScope_KeyList>` for a list of keycode
|
|
constants.
|
|
constants.
|
|
|
|
|
|
Mouse events
|
|
Mouse events
|
|
@@ -278,7 +278,7 @@ also counts as a button - two buttons, to be precise, with both
|
|
switch ((ButtonList)mouseEvent.ButtonIndex)
|
|
switch ((ButtonList)mouseEvent.ButtonIndex)
|
|
{
|
|
{
|
|
case ButtonList.Left:
|
|
case ButtonList.Left:
|
|
- GD.Print($"Left button was clicked at {mouseEvent.Position}");
|
|
|
|
|
|
+ GD.Print("Left button was clicked at ", {mouseEvent.Position});
|
|
break;
|
|
break;
|
|
case ButtonList.WheelUp:
|
|
case ButtonList.WheelUp:
|
|
GD.Print("Wheel up");
|
|
GD.Print("Wheel up");
|