Is there a default way to detect whether the input came from a keyboard or controller?

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

I want to be able to show different controls on the UI depending whether the player pressed on the keyboard or the controller, not just if he has the controller connected. Is there a method of some class like Input that would tell me whether the input came from a controller or keyboard?

:bust_in_silhouette: Reply From: Jams

I just got started with Godot, so there might be better ways, but I believe you can use…

func _input(event)
    if(event is InputEventKey):
        # Do stuff
    elif(event is InputEventJoypadButton):
        # Do stuff
    elif(event is InputMouseButton):
        # Do stuff
    elif(event is InputEventScreenTouch):
        # Do stuff
    else:
        # Do stuff