Author Topic: Does QB64 have this funcitonality?  (Read 2873 times)

0 Members and 1 Guest are viewing this topic.

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Does QB64 have this funcitonality?
« on: September 28, 2019, 03:28:41 pm »
is there anyway to monitor for any keyboard input via _KEYDOWN? or does it have to monitor for explicit key codes?
as in;  Nul=_KEYDOWN(20480)

or is there an option I'm missing like; Nul = _KEYDOWN(*)
where '*'=wildcard

something I could use it to processes an input handler when any key is held down,  When I use INKEY$ or _KEYHIT there is often a pause before the routine called by my _KEYDOWN line  does its thing.

I am wondering if I could pull this code off:
Code: QB64: [Select]
  1.  
  2. IF _KEYDOWN THEN Input_Controls
  3.  
  4. LOOP UNTIL ExitFlag%% = -1
  5.  
  6. SUB Input_Controls
  7. IF _KEYDOWN(20480) then do something
  8. IF _KEYDOWN(18432) then do something else
  9. ...
  10. ...
  11. ...
  12. IF _KEYDOWN(65) then do something magical
  13. ...
  14. ...
  15. ... so on and so on
  16.  

so my program doesn't waste a lot of time looking for any keys down unless there is one to find. And without the pause that seem inherent when using either _KEYHIT or INKEY$ to watch for it.
Granted after becoming radioactive I only have a half-life!

FellippeHeitor

  • Guest
Re: Does QB64 have this funcitonality?
« Reply #1 on: September 28, 2019, 04:07:20 pm »
I’d keep checking the required keys alone. No such burden on the processor.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Does QB64 have this funcitonality?
« Reply #2 on: September 28, 2019, 04:07:43 pm »
I’m thinking _DEVICES would be the easiest way to go to do this.

devices = _DEVICES
DO
  If _DEVICEINPUT = 1 THEN Input_Controls ‘keyboard input

LOOP

SUB Input_Controls
    IF _BUTTON(uparrowcode) THEN do something
    IF _BUTTON(leftarrowcode) THEN do something else
...
...
...
     IF _BUTTON(65) THEN do something magical with Capital “A”.
...
...
... so on and so on
END SUB
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!