I’m trying to implement the new input system package in my Unity 3d project to make my input work even when the application is not focused. I created my own input actions with the respective events connected to the pressing of some keyboard keys (bindings) and I also activated all the settings relative to my application’s background behaviour. My problem is that by setting the bindings as keycodes they are not recognized in the background and the input is redirected to Windows. If instead the bindings are buttons on a joystick then the input can reach my game even if is it running in background. Does anyone know how to make keyboard input work in background?
Reading keyboard input in the background is not supported since its in most cases not supported by the underlying operating system / platform and hence there is no way for us to expose it in Unity APIs when not having application/keyboard focus. The motivation for this is typically security related to prevent malicious applications such as key loggers and similar. Other types of devices such as gamepads or gaming HID devices in general may support background input and is what you have already observed.
As a side-note, the behavior of the Input System with respect to devices that allow input to be read when not having application focus may be configured in the Settings of the input system, see Input settings | Input System | 1.7.0.
Note however that this may be limited what is allowed or possible on the targeted platform/OS.