def key_press(key):
    """Simulates a key press event.

    Sends a scancode to the computer to report which key has been pressed.
    Some games use DirectInput devices, and respond only to scancodes, not
    virtual key codes. You can simulate DirectInput key presses using this
    method, instead of the keyevent(...) method, which uses virtual key
    codes.

    :param key: A string indicating which key to be pressed.
                Available key options are listed in KEYS and EXTENDED_KEYS.
    """
    try:
        key_name = key.upper()
    except AttributeError:
        raise ValueError('invalid literal for key_press(): {}'.format(key))
    try:
        hex_code = KEYS[key_name]
    except KeyError:
        pass
    else:
        flags = KEYEVENTF_SCANCODE
        send_keyboard_input(hex_code, flags)
        return
    try:
        hex_code = EXTENDED_KEYS[key_name]
    except KeyError:
        raise ValueError('invalid literal for key_press(): {}'.format(key))
    else:
        flags = win32con.KEYEVENTF_EXTENDEDKEY | KEYEVENTF_SCANCODE
        send_keyboard_input(hex_code, flags)
Simulates a key press event.

    Sends a scancode to the computer to report which key has been pressed.
    Some games use DirectInput devices, and respond only to scancodes, not
    virtual key codes. You can simulate DirectInput key presses using this
    method, instead of the keyevent(...) method, which uses virtual key
    codes.

    :param key: A string indicating which key to be pressed.
                Available key options are listed in KEYS and EXTENDED_KEYS.
    
airtest/core/win/ctypesinput.py