How to detect whether keyboard/mouse or controller was interacted with last

Ah yes, apparently I set the input mode to FInputModeUIOnly when I bring up my UI screens (pause menu, for example). I guess I could stop doing that and find a different way to tell the game to ignore control inputs while the UI is visible, but that feels like an inelegant workaround rather than a good solution. I’ll give it a go though. Thanks.