Fix keyDown event handling for macOS input methods (#21906)