I have an init_keys() function that loads the scan codes for the control keys from external file and set them to variables with meaningful names (like key_jump_scan, key_shoot_scan .. etc.) ,then update_keys() that runs every frame that sets the state of every key to another kind of variable (like: key_jump, key_shoot ... etc.) using key_pressed(scan_code) function:

Code:
while(1)
{
   ...
   key_jump = key_pressed(key_jump_scan); //key_jump_scan was already set to the scan code of the desired key in the previous init_keys() function
   
   ...
   wait(1);
}



Then, inside the main code that controls whatever kind of key-based behaviour, i use the key_something variable like:

Code:
...
movement_speed.x = (key_forward-key_backward)*10*time_step;
...