Keyboard input from a user in widget

I would like to ask how it is possible (in a widget) to capture the keyboard key pressed by the user? I would like to create widget where the user can change key mappings. Changing keys themselves is not a problem, but getting a key from the user is a bit more problematic. For example the key is shift and the user wants to change it to alt. After pressing the change key button, blueprint waits for the key input and when the user press alt, the alt key name is displayed and saved in the system.