Store a keycode in a variable, and pass that into the keyboard events to check whether that key is pressed, etc. Then you can change that variable to whatever new keycode you need it to be via some menu. You'll have to set up the menu system yourself though, which will be a pain, since there aren't any simple ways to handle menus, and that sort of thing.