INP() keyboard handling - Printable Version +- Qbasicnews.com (http://qbasicnews.com/newforum) +-- Forum: QBasic (http://qbasicnews.com/newforum/forum-4.html) +--- Forum: QB Discussion & Programming Help (http://qbasicnews.com/newforum/forum-11.html) +--- Thread: INP() keyboard handling (/thread-8505.html) |
INP() keyboard handling - jony_basic - 12-05-2005 I am working on a game in QB 4.5 and I would like to make a multy key function. I tried some ASM things like fastkey.bas, but they didn't seem to work well on my machine. then I heard from source (http://faq.qbasicnews.com/?blast=ChrTwo) in Qbasicnews.com that says I can use INP(96) for keyboard input. If I can get key press and key realease, I can do some sort of multykey, if there is another way, that would be great too. your help is very much appreciated. Jony_Basic INP() keyboard handling - red_Marvin - 12-05-2005 While I can't really remember any solid facts for the moment, you could always fool around and educate yourself with this code: [syntax="qbasic"]dim theinput as integer, oldinput as integer do theinput=inp(96) if theinput<>oldinput then print theinput oldinput=theinput end if loop[/syntax] thanks - jony_basic - 12-06-2005 Thanks a lot for this, I will try a few things out with it. I got an assembly multikey sub to work though, it seams to work fine for now. :oops: Thanks again Jony_Basic INP() keyboard handling - axipher - 12-07-2005 wats the code you used, im just wonderin, a multi-key system would be nice INP() keyboard handling - Anonymous - 12-07-2005 http://www.qbasicnews.com/abc/showsnippet.php?filename=KEYBOARD.ABC&snippet=30 for all newbs: click on the "ABC" up by Qbasicnews.com on top of the screen. tons of code to give you examples (thank na_th_an) INP() keyboard handling - axipher - 12-07-2005 that text the link links to is a bit buggy, the little thing jumps, and really i don see wat its for INP() keyboard handling - na_th_an - 12-07-2005 I've used that code in many games. It works perfectly. It's just a keyboard handler. You call it with the scancode of the key you want to test. Scancodes can be found in the QB help. For example, to test if the UP cursor key is pressed you call MULTIKEY(72), as 72 is the scancode for the UP cursor key. Code: IF MULTIKEY(72) THEN INP() keyboard handling - axipher - 12-08-2005 well its just that when i used that code, the little object moved sometimes 1 space over and sometime jumped like 5 INP() keyboard handling - na_th_an - 12-09-2005 That's an OS fault. That code reprograms the machine timer to get a higher frame rate, but that doesn't work right in Windows XP. In fact, no timing routine in a MSDOS program will work right in Windows XP. Note that QB is a MSDOS compiler and you are not running it in MSDOS. You can try Milo Sedlaceck's keyboard handler, it doesn't touch the timer: http://faq.qbasicnews.com/?blast=MiloSedlaceckKeyboardHandler Another solution I've used to have a fast pseudo-multikey "keyboard handler" (add tons of quotes :lol for simple games and programs is this: http://faq.qbasicnews.com/?blast=AltCtrlShifs If you use CTRL for left, ALT for right and SHIFT for jump, you got it INP() keyboard handling - axipher - 12-09-2005 Thanks alot for the links, although I switched to fb for now, when I ran my program, the screen was 3 SCREEN 13 pixels off to the left and right of my screen, it worked on some computers ok, but with fb as the compiler, since it's not DOS, the screen is displayed properly. |