# How do I cancel flipping?

Attention Topic was automatically imported from the old Question2Answer platform.

hello,
I’m new and I currently set up my character to flip left and right by using “left” and “right” keys respectively.
currently, if I hold “left” and press “right” my character does not flip (which is exactly what I want).
but, while holding down “right”, if I press “left” my character flips.
how do I make it so that pressing two keys at once cancels flipping?

``````export (int) var speed = 480

var velocity = Vector2()

func get_input(): # movement and flip
velocity = Vector2()
if Input.is_action_pressed("right"):
velocity.x += 1
\$Sprite.flip_h = true
if Input.is_action_pressed("left"):
velocity.x -= 1
\$Sprite.flip_h = false
if Input.is_action_pressed("down"):
velocity.y += 1
if Input.is_action_pressed("up"):
velocity.y -= 1
velocity = velocity.normalized() * speed
``````

You can check for left and right simultaneously which will cancel the movement and flipping

``````export (int) var speed = 480

var velocity = Vector2()

func get_input(): # movement and flip
velocity = Vector2()
if not (Input.is_action_pressed("right") and Input.is_action_pressed("left")):
if Input.is_action_pressed("right"):
velocity.x += 1
\$Sprite.flip_h = true
if Input.is_action_pressed("left"):
velocity.x -= 1
\$Sprite.flip_h = false

if Input.is_action_pressed("down"):
velocity.y += 1
if Input.is_action_pressed("up"):
velocity.y -= 1
velocity = velocity.normalized() * speed
``````