Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 11:17 01 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Alternatives for KEYDOWN in MMBasic 5

Author Message
karjo238
Regular Member

Joined: 12/10/2018
Location: New Zealand
Posts: 60
Posted: 02:22am 25 Aug 2019
Copy link to clipboard 
Print this post

Sigh.....

*Hopefully* this will be the last question I need to ask here, because everything else I'm doing has been sorted, so here we go....  

I note that KEYDOWN has been removed from MMBasic for the Micromites because it was never meant as a games playing platform, and yet here I am stubbornly trying to do what shouldn't be done.

I know that INKEY$ is available, but that won't help me capture arrow button presses or multiple keypresses at once (I could be wrong tho...) The alternative I can see is ON KEY target, which when I set up a short test program detects all the keys I need. The one problem I have is being able to read the value of the keypress that triggers this.

Can somebody enlighten me as to whether this value can be obtained, if at all?

If this is a dead end, I can always go to INKEY$, but in an ideal world, I would really like to use the arrow keys.

Again and as always, many thanks. This forum really has been such a godsend for my stubbornness.

Joseph  
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 02:45am 25 Aug 2019
Copy link to clipboard 
Print this post

What device are you using?

KEYDOWN was removed from MMBasic for the Micromites because the only chance you have of detecting multiple key presses is with a directly connected keyboard.

Anything else depends on the terminal program being used.

The arrow keys should be detected OK:
up arrow chr$(128)
down arrow chr$(129)
left arrow chr$(130)
right arrow chr$(131)

Jim
VK7JH
MMedit
 
SimpleSafeName

Guru

Joined: 28/07/2019
Location: United States
Posts: 351
Posted: 03:06am 25 Aug 2019
Copy link to clipboard 
Print this post

If you knew the address of where the keys came in to the firmware, you could use PEEK.

Ah, like this:

do
print @(100,1)
for i = 0 to 255
 x=PEEK(KBUF,i)
 if x<10 then
  a$="  00"+str$(x)
 elseif x<100 THEN
  a$ = "  0"+str$(x)
 else
  a$ ="  "+str$(x)
 endif
 print a$;
next
Loop
Edited 2019-08-25 16:20 by SimpleSafeName
 
karjo238
Regular Member

Joined: 12/10/2018
Location: New Zealand
Posts: 60
Posted: 01:40am 26 Aug 2019
Copy link to clipboard 
Print this post

  TassyJim said  What device are you using?

KEYDOWN was removed from MMBasic for the Micromites because the only chance you have of detecting multiple key presses is with a directly connected keyboard.

Anything else depends on the terminal program being used.

The arrow keys should be detected OK:
up arrow chr$(128)
down arrow chr$(129)
left arrow chr$(130)
right arrow chr$(131)

Jim


Hey Jim! Apologies, I should have mentioned I'm using a Micromite Extreme 144. I'm using a PS/2 keyboard and a VGA monitor, so it's standalone, which is one of the main reasons I like these systems.

I have got INKEY$ to work, but given that I'm writing a game, it's not the greatest solution, so if there is a better one, I would be most gratified to hear about it.

Manny thanks as always,

Joseph.
 
karjo238
Regular Member

Joined: 12/10/2018
Location: New Zealand
Posts: 60
Posted: 12:12am 08 Sep 2019
Copy link to clipboard 
Print this post

Can anyone help here, or is there no alternative to inkey$? Apologies if bumping a thread is bad form on this forum, but I'd just like to get a definitive answer to this.

Many thanks,

Joseph.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 07:25am 08 Sep 2019
Copy link to clipboard 
Print this post

Give me a day or two and I'll include it in the MMX firmware
 
karjo238
Regular Member

Joined: 12/10/2018
Location: New Zealand
Posts: 60
Posted: 07:10am 11 Sep 2019
Copy link to clipboard 
Print this post

Sorry for the late reply, but thank you so much! It will make what I'm trying to do that much easier (and better, for that matter!)

It's gratifying to be able to reach out and get help like this when you need it. Yay for the Internet! :D

Joseph.
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025