newKey with numeric choices

PennController for IBEX Forums Support newKey with numeric choices

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #6818
    mg5171
    Participant

    Hello,
    I am trying to do some feedback after a practice item. I found the following on the documentation, and it works in my script:

    newKey("forj", "fj")
        .wait()
    ,
    getKey("forj")
        .test.pressed("f")
        .success( newText("success", "You're right!").print() )
        .failure( newText("failure", "You're wrong, 0.999... and 1 do refer to the same number").print() )
        ,

    However, I’d like the keys to be 1 and 2 instead (ABX task, so numeric keys make more sense). But when I change ‘fj’ to ’12’, and change it in test.pressed (.test.pressed(‘1’)), it stops working. Any idea why? Is it something with numeric keys?
    Thanks!

    #6820
    Jeremy
    Keymaster

    Hello,

    PennController should automatically detect when the argument is an actual number, or a string exclusively consisting of digits. Visibly it fails to do so, and therefore expects a keypress producing the character with code 12, which is inaccessible in a single keystroke.

    To fool PennController, add a dummy non-digit character to your digit string, for example (this one’s called the “replacement character,” I doubt anyone would have configured their keyboard to type it in a single keystroke):

    newKey("1or2", "�12")
        .wait()
        .test.pressed("1")
        .success( newText("success", "You're right!").print() )
        .failure( newText("failure", "You're wrong, 0.999... and 1 do refer to the same number").print() )
    

    Jeremy

    #6821
    mg5171
    Participant

    Thanks for helping me fool the system! Works perfectly.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.