Qbasicnews.com
May 26, 2020, 05:18:12 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: keyboard config  (Read 2689 times)
Anonymous
Guest
« on: November 09, 2003, 03:01:44 PM »

Hi i have a question. you know how when you hold a key, it delays for a second, and then repeats at a set timing? well, how do you make it so theres no delay?? i used to know this. i think it has something to do with an environment setting in dos, but is there a way to do it purely in qb? thanx   :bounce:
Logged
Oz
I hold this place together
*****
Posts: 923



« Reply #1 on: November 09, 2003, 03:27:47 PM »

This code snippet should work:

Code:

dim KeyPress as integer   'This does not have to be an array...
Do    'To initiate your loop
KeyPress = INP(&h60)    'I think its 60....haven't used it in a while

select case KeyPress
  case <Hexidecimal code for key>
end select

loop until <Condition1> <math function)> <Condition2>


If that doesn't work, e-mail me!

Alex
Logged
Anonymous
Guest
« Reply #2 on: November 09, 2003, 03:37:37 PM »

dude thanx a lott!!!   Cheesy  I shyed away from using that a while ago cause it started messing up my comput and making the mouse act all random. screw it... its working now! thanx again
Logged
Oz
I hold this place together
*****
Posts: 923



« Reply #3 on: November 09, 2003, 03:44:52 PM »

Its my job to help.....the only problem w/the code i gave you is when you press over 5 keys, it will start to beep when you press a key....it may just be my computer...i dunno

o well

Alex
Logged
Anonymous
Guest
hey
« Reply #4 on: November 09, 2003, 05:04:21 PM »

hey check it out you can get rid of that beeping with this:
Code:
DEF SEG = 0: POKE &H41A, PEEK(&H41C): DEF SEG
and... unfortunately that code didnt hold up to my vigorous  Cool testing... try this.
Code:
SCREEN 13

LOCATE 1, 1: PRINT "hit esc to quit"

DO

 DEF SEG = 0: POKE &H41A, PEEK(&H41C): DEF SEG
 Keyp = INP(&H60)

 SELECT CASE Keyp

  CASE 72
  y = y - 1

  CASE 75
  x = x - 1

  CASE 77
  x = x + 1

  CASE 80
  y = y + 1

  CASE 1
  END

 END SELECT

 PSET (x, y)

 FOR p = 1 TO 1000
 NEXT

LOOP
just go all random and eventually itll hang up on you. (unless its just my computer) Tongue why does everyone think that?! lol well if someone else knows code where this wont happen please share, k?
Logged
toonski84
__/--\__
*****
Posts: 2567



« Reply #5 on: November 09, 2003, 05:59:21 PM »

Code:
DEF SEG = 0: POKE &H41A, PEEK(&H41C): DEF SEG


while that's cleaner,

Code:
null$ = inkey$


clears the key buffer all the same.  But your code, besides looking fine, works fine on my computer.  &H60 (96), is how any program gets keys from the keybuffer without that handy keypress delay (thogh asm programs use an interrupt vector to get every key's status).

try downloading a program called 'multikey.bas' by the late milo sedlack.  It's simple, uses assembly and I think you'll like it.  If you're using any major qb library DQB, CosmoX, etc), all of those have a keyhandler.  I dont know about UGL, but it might (and should).
Logged

i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Anonymous
Guest
« Reply #6 on: November 09, 2003, 06:16:50 PM »

i know the codes good... maybe it IS just my computer... like i run the prog, and move it all around random and (almost) evry time i turn it hangs for like 1/2 second and then keeps going.. i dont know why at all hey thanks for trying out my code on ur computer tho. i dunno my cpus all in compatibility mode paging so maybe that has somethin to do with it
Logged
Neo
Na_th_an
*****
Posts: 2150



« Reply #7 on: November 10, 2003, 06:02:10 AM »

If you use INP(&H60) be sure to do this:

Code:
FUNCTION neoKeybInkeyScan%
   keyp% = INP(&H60)
   IF keyp% < 128 THEN neoKeybInkeyScan% = keyp% ELSE neoKeybInkeyScan% = 0
END FUNCTION
Logged
Anonymous
Guest
« Reply #8 on: November 10, 2003, 12:46:58 PM »

Well, I tried that and it worked pretty much like the regular
Code:
INP(&H60)
... I inserted a
Code:
LOCATE 1, 30: PRINT Keyp

inside the main loop so I could see what was happening when it hung up after the turns, and every time it hangs up, Keyp becomes 0 for that amount of time; even when I'm clearly holdin the key. It makes NO SENSE!!! Am I the only one this happens to??
Logged
toonski84
__/--\__
*****
Posts: 2567



« Reply #9 on: November 10, 2003, 01:13:01 PM »

well, just out of curiosity, are you using windows xp or something that emulates dos?
Logged

i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Meg
Ancient QBer
****
Posts: 483


« Reply #10 on: November 10, 2003, 02:41:18 PM »

I'm sure this has already been tried, but can't you change these settings with a dos command:

Code:
SHELL "MODE CON: rate="+LTRIM$(STR$(r%))+" delay="+LTRIM$(STR$(d%))


where d% = 1 thru 4 and r% = 1 thru 32

set d% to 1 (it's defaulted to 2), and it will decrease the delay before the key start repeating.

*peace*

Meg.
Logged
Anonymous
Guest
« Reply #11 on: November 10, 2003, 04:50:59 PM »

oh THANK YOU so much megg you are freakin awesome thats exactly what i was lookin for was the DOS command. yesss you rock thanks  Cheesy
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!