How to check if a key is pressed in Renpy?

77 Views Asked by At

I am making a visual novel in which I need to check if a key, let's say "a" is pressed, and jump to a label when the key is pressed.

For more context, in my game, the character say 3 sentences, 1 is right and the others are wrong, I need to check if "a" which is the key to "denounce" the information said is pressed, if it is pressed on a wrong sentence, it jump to the "fail" label, if the key is pressed on the right sentence it jump to the "success" label.

Here's the code:

# Here the A key is used to say that the information is True 
# If it is true, we go to the success label
# if not, we go to the failure corresponding label
# which goes back to where we made a mistake

label Testimony:
    Policeman "information 1"
    # if A pressed: 
        jump fail_T1
    # Else:
        jump T2
label T2:

    Policeman "information 2" # True information
    # If A pressed: 
        jump success
    # Else:
        jump T3
label T3:

    Policeman "information 3"
    # if A pressed: 
        jump fail_T3
    # Else:
        jump Testimony`

I tried to ask on discord server, check the renpy doc, on YouTube, I asked chatgpt but I don't find how to make what I want, and I don't want clickable buttons, I want to check if a key is pressed.

0

There are 0 best solutions below