How to get mouse press/release state via script


I know it is possible, to fire an event when a mouse button is pressed or release in Blueprint.(press anywhere, not on certain Actor)
But how can i do this in Script, c++?

I only know a way that is to bind input by:
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;

But I would like input bindings to be clean. So is it possible?

You can check state of any input button with this function in Player Controller

Also there tick friendly version so you don’t need to track if button was already pressed or released:

You can not do this with input actions directly, you need get bindend key from InputComponent first