how to do key sensing in python

import keyboard, time

# Continuously check if 'c' key is pressed

while True:
  if keyboard.is_pressed('c'):
    print('The c key was pressed')

Here is what the above code is Doing:
1. The while loop will run continuously until the user presses the ‘c’ key.
2. The if statement checks if the ‘c’ key is pressed.
3. If the ‘c’ key is pressed, the program will print ‘The c key was pressed’.