InputEventMouseMotion does not work when pressing keys

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Unityfugee

I want to move a camera using the mouse (laptop touchpad), but the function to detect mouse movement does not work when I also press any key.

Do you know how to fix this or any alternate function to detect mouse movement ?

Here is the script:

func _input(event):
    if event is InputEventMouseMotion:
        print("a")
    else:
        print("b")

It prints a when I’m only using the touchpad and b when I’m also using keys

:bust_in_silhouette: Reply From: Yuminous

It’s probably not Godot which is causing that problem but your computer… or lag?

For reference: on my computer that code prints aa... when using my mouse and ab... when using my mouse and keyboard — what you would expect.

Godot like any game engine will try and record all input events every frame, but Godot won’t actually send those events until the frame is rendered (to save performance!), but you can disable that behaviour.

Maybe on your system that’s not working quite right? Try this:

func _ready():
   set_use_accumulated_input(false)

Is your system lagging? And do you have a wired mouse you could try out? Can you move the mouse while typing normally?

On second inspection, my touchpad never works when typing, even on non-Godot games. It seems to work with a mouse.

Unityfugee | 2021-07-12 15:32