You can do that in APlayerController::SetInputMode, it’s callable from blueprint. I usually call it in the Construct event script of the widget (or in the NativeConstruct override if the widget is in C++), I use various kind of InputModes for different kind of widgets in my game.