title: if statment in while loop partially working
body: <p>so I was doing one of the exercises to practice python (sorry guys, just learning). Exercise is asking to do it in a while loop. So I did, unfortunately, it doesn't fully work and I have no idea why, as a similar exercise I did is working properly (in while loop as well using keyboard).</p>
  <pre><code>import keyboard
      
  while True:
      if keyboard.is_pressed('1'):
          try:
              speed_1 = int(input('What was your speed an hour? '))
              time_1 = int(input('For how long have you been driving? Please input your time in minutes. '))
              distance_1 = (speed_1 / 60) * time_1
              print('Distance you have traveled is ' + str(round(distance_1, 2)) + ' km.')
              break
          except ValueError:
              print('You need to use numbers.')
      elif keyboard.is_pressed('2'):
          try:
              distance_2 = int(input('How far do you want travel? Enter in km. '))
              time_2 = int(input('How long do you have to get there? Enter in minutes. '))
              speed_2 = time_2 / distance_2 * 100
              print('You need to drive ' + str(round(speed_2, 2)) + ' km/h to get there on time.') 
              break
          except ValueError:
              print('You need to use numbers.')
      elif keyboard.read_key() != '1' and keyboard.read_key() != '2':
          break
  </code></pre>
  <p>As you can see this is a basic speed, distance calculator. If I press one it will work, if I press 2 it doesn't work at all.. just get stuck not doing anything, pressing any other key works just fine.. it closes a program. What have I done wrong? Any ideas? I know this is probably not worth it to waste my time on it, as it is only exercise, but I've tried to find out why I can't do it that way and why it does work ok apart from when I press 2.</p>
  <p>EDIT:
  just realized, if I press 2 nothing will happen, but if I will press 1 or any other button after pressing 2, it will either proceed with if or it will close the program.</p>