Encoding of numeric keys
Hello,
The keybord element recognizes the keys of the numeric pad via the labels that are documented : "NUM_1", "NUM_2", and so on. But if I reference those keys in an in-line script like:
if var.response_Saisie_4 == "NUM_1":
var.idim = 1
the assignment does not work (in this example, idim keeps its original value of 0).
Where is the error ?
Thank you in advance,
Gérard
Comments
Hi @gerhono ,
The
keyboard_responseitem has a list of synonyms for keys. However, when you're checking the value of a variable in a Python script, then of course the match has to be exact. I would print out the value ofvar.response_Saisie_4to see what it is exactly:— Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi Sebastiaan,
Thanks for your fast reply. The value is:
num_1 <class 'str'>
I learn pieces of Python by analogy according to my needs and I had tested that if I use a letter key, the test works:
if var.response_Saisie_4 == "a":
var.idim = 1
So, what's the difference with "NUM_1" ?
It's lowercase 😉
Check out SigmundAI.eu for our OpenSesame AI assistant!
THANK YOU !
I guess I should take time to learn Python ...
😊
Gérard