How to detect if any gamepad button was pressed

Is there any way I can detect any button press or joystick move on a gamepad like Input.anyKeyDown gives me true when any keyboard or mouse key was pressed?

I’m looking for a one-line solution. It seems redundant and a little overkill to loop through every button just to check if one of them was pressed, since I’m using Unity’s input class already. I basically want to detect if a player wants to use the gamepad or the keyboard during runtime, by checking if either receives input and then switch my input method in game accordingly.

Thank you!

I might use a raycast, if hit UI layer, you could run thru the bounds of each UI btn. If hit.point lands in bounds of any one UI btn then that btn was interacted with.