How do i stop the input of other directional keys?

I’ve set up a capsule on my character that moves to the direction of where the character is facing, but if i press more than one key at a time, my character flies off the map. i need to set up something that either overrides the current key that is being pressed, or prevents the other key from being activated before the current key is released.