Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 08:28 14 Jun 2026 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 : Help with Picomite INKEY$ Function

Author Message
apalert
Regular Member

Joined: 06/07/2023
Location: Australia
Posts: 47
Posted: 01:06pm 11 Jun 2026
Copy link to clipboard 
Print this post

Looking to wait for Up or Down arrow to be pressed. Just to test the idea I've been inputting this and similar at the command prompt but doesn't work as hoped!

x=1 : do : loop while inkey$="" : if inkey$ = chr$(128) then x = x+1  : Print x
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 11465
Posted: 01:17pm 11 Jun 2026
Copy link to clipboard 
Print this post

inkey$ consumes the keypress so you can't read it again
Do
x=1
s$=Inkey$
Loop While s$=""
If s$=Chr$(128) Then x=x+1:Print x
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 3279
Posted: 01:22pm 11 Jun 2026
Copy link to clipboard 
Print this post

To make it work on one line:-
> x=1 : do : loop until inkey$ = chr$(128) : inc x : Print x
2
>
 
apalert
Regular Member

Joined: 06/07/2023
Location: Australia
Posts: 47
Posted: 08:52pm 11 Jun 2026
Copy link to clipboard 
Print this post

Thanks Peter as always!

Thanks Phil, you've woken me up to using the INC function as well! I figured you can get a decrement using INC variable, -1. Oh boy, when I think of the copious variable = variable + 1 and variable = variable - 1 in my code. Not only does INC look slick, the manual says it processes much faster.

I actually want bigger steps than 1 so I've ended up, as a demo for using both Up and Down keys, with:

dim float x
dim string s$

x=10
do
Do
 s$=Inkey$
 Loop While s$=""
If s$=Chr$(128) Then inc x,10:Print x
If s$=Chr$(129) Then inc x,-10:Print x
loop
 
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 2026