I'm afraid it depends on your way to handle inputs for the player.
If you are just using the default controls, I don't think it can work, other than if the user uses the arrow key in diagonal and release both keys at the same time (using all the default configuration of the 8 direction behavior, the character stays in diagonal).
Otherwise, you would need to put some kind of buffer in your input handling and when the character was going in diagonal, check for some time between the moment the keys are released, so that even if the last input was a single arrow, you would still believe the intent was to go in diagonal.