Solved by user @furas in the comments here, keyboard.press() keeps the button pressed, so the code needed keyboard.release() for to avoid the initial keyboard.press() being held in for the rest of the loops.
keyboard.press()
keyboard.release()