Skip to main content
1 of 2

UNITY: UI Use Buttons based on Key Presses instead of Mouse Click

I have a UI Button. I want a function to be called whenever I press a specific Key on my Keyboard while my mouse is hovering over the button.

The Button Component On Click () has not received keypress input, only mouse clicks.

I am using the New Unity Input System

Similar to in Ark SE where you can press T while hovering over an item in your inventory to transfer it.

I have tried using a Raycast from ScreenPointToRay however this did not work as I do not have colliders on my UI and it is part of a Canvas