• Question on "onekey" python function

    From lemonlime@21:4/162 to All on Friday, October 25, 2019 00:51:02
    Hi All,

    I'm trying to modify a .mpy python script to also 'break' when enter is
    pressed instead of just Q.

    The script just gets user input into the "char" variable as below:

    char = bbs.onekey("AVQ",True)

    And then there are if statements to make the A, V and Q keys do stuff. I know that enter is considered chr(13) in mystic python, but I don't know if the onekey function can accept special keys (enter, escape etc). I also tried the getkey function but that doesn't seem to work for me either.

    Any tips or suggestions?

    Thanks,
    Mike

    --- Mystic BBS v1.12 A43 2019/03/02 (Linux/64)
    * Origin: Stellar Darkness BBS (21:4/162)
  • From lemonlime@21:4/162 to All on Friday, October 25, 2019 01:25:19
    char = bbs.onekey("AVQ",True)

    And then there are if statements to make the A, V and Q keys do stuff. I know that enter is considered chr(13) in mystic python, but I don't know if the onekey function can accept special keys (enter, escape etc). I
    also tried the getkey function but that doesn't seem to work for me either.

    Figured it out. Was just the syntax/formatting that was throwing me off :)

    char = bbs.onekey(chr(13) + 'AQV', True)

    The above did the trick.

    --- Mystic BBS v1.12 A43 2019/03/02 (Linux/64)
    * Origin: Stellar Darkness BBS (21:4/162)
  • From maskreet@21:1/114 to lemonlime on Friday, October 25, 2019 15:06:27
    On 25 Oct 2019, lemonlime said the following...

    Figured it out. Was just the syntax/formatting that was throwing me off
    :)

    char = bbs.onekey(chr(13) + 'AQV', True)

    I was actually in the middle of replying to you about this last night before
    I went to sleep. Was dog-tired, though. Glad you got it figure out!

    --- Mystic BBS v1.12 A43 2019/03/02 (Linux/64)
    * Origin: throwbackbbs.com -\- meriden, ct -\- (21:1/114)
  • From g00r00@21:1/120 to lemonlime on Friday, October 25, 2019 23:24:06

    char = bbs.onekey("AVQ",True)

    ch = onekey(chr(13) + 'AVQ', True);

    Thats all you have to do for ENTER. 27 for ESCAPE etc. It all works.

    --- Mystic BBS v1.12 A43 2019/03/02 (Linux/64)
    * Origin: Cyberia BBS | cyberiabbs.zapto.org | San Jose, CA (21:1/120)
  • From lemonlime@21:4/162 to g00r00 on Tuesday, October 29, 2019 13:45:03
    ch = onekey(chr(13) + 'AVQ', True);

    Thats all you have to do for ENTER. 27 for ESCAPE etc. It all works.

    Thanks g00r00 - I wound up finding it earlier in one of the example mpy
    scripts and it works perfectly.

    --- Mystic BBS v1.12 A43 2019/03/02 (Linux/64)
    * Origin: Stellar Darkness BBS (21:4/162)