A lightweight low-level global windows keyboard hook compatible with modern UI frameworks (WPF, MAUI, WinUI 3, etc.)
$ dotnet add package KeyboardHookLite
It is essentially the same as the code for the console application above. You can omit System.Windows.Threading.Dispatcher.Run(); as UI frameworks already have a message queue. You can initialize the keyboard hook wherever you choose, whether it be upon a click or when the screen is initialized. Please remember to dispose (kbh.Dispose();) when you no longer require the hook.
KeyboardHookEventArgs contains the property KeyPressType and InputEvent which is of type LowLevelKeyboardInputEvent. See below for what that entails. If you would like to add further functionality, you can do so by adding properties to the KeyboardHookEventArgs class.

MIT