![]() |
Forum Index : Microcontroller and PC projects : CMM2: On Key Escape fun and games
Author | Message | ||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4311 |
Noticed this in MMB4L and it's present on the CMM2 too: > list "on_key_test.bas" On Key 27, do_quit Do Loop Sub do_quit End End Sub Run this and press one of the cursor keys, the program will end and display the remaining ANSI code for the cursor key without the leading escape character. e.g. press [UP] and you get [A Possibly it's fixable, but might be simpler and not too limiting to add restrictions to valid ASCII codes for ON KEY ? Best wishes, Tom Edited 2021-10-27 00:59 by thwill MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10310 |
Doesn't need fixing IMHO - buyer beware There are good reason why non-ascii are useful OPTION BREAK 4 on key 3, tidyexit sub tidyexit ' close things as required option break 3 end sub |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4311 |
Yes, I've done that myself on your suggestion, but ON KEY 27 is going to catch more than the [Escape] key and it screws up a bunch of other keys which is why I'm wondering if it either needs guarding against or handling better ... though the latter would be messy. Best wishes, Tom MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4311 |
Not that I imagine you would change it, but is there a second use case for either ON KEY <code>, or OPTION BREAK <code>? If not then couldn't they be replaced with ON BREAK ? Best wishes, Tom Edited 2021-10-27 02:51 by thwill MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
jirsoft![]() Guru ![]() Joined: 18/09/2020 Location: Czech RepublicPosts: 533 |
Hi Tom, I'm using ON KEY 157, NCprintScreen for screenshots... Jiri Napoleon Commander and SimplEd for CMM2 (GitHub), CMM2.fun |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
I assume you are using a terminal program, not a connected keyboard. the up arrow VT code is esc [ A so your program is working as programmed. If you cater for terminal programs, you will have to wait for a time after the esc to see if any characters follow before treating it as escape alone. Jim VK7JH MMedit |
||||
Goksteroo Senior Member ![]() Joined: 15/03/2021 Location: AustraliaPosts: 114 |
Why didn't I think of that - DOH! |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4311 |
Thanks Jim, On the CMM2 "yes", and it doesn't usually happen if you use a USB keyboard ... though very occasionally I do seem to get it ![]() On MMB4L the keyboard is connected, but MMBasic does run inside a local terminal and thus sees the VT codes rather than reading directly from the keyboard; MMB4L currently has no KEYDOWN function for this reason. If you cater for terminal programs, you will have to wait for a time after the esc to see if any characters follow before treating it as escape alone. Yes, I know, I understand, and that happens in the general keyboard input case, but MMB4L (like the CMM2) runs the code for intercepting/handling ON KEY <code> before the code that identifies and combines VT escape codes from the input into single bytes. No action from anyone expected, just building up my knowledge. Best wishes, Tom MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |