Main
   Home
   About
   DiscussionBoard
Files
   About
   Submit
   Search
Downloads
   Action
   QB64
Links
   Link to us
QB45.org
[ Back to QB45 | FAQ | Search a message | Reply to this message | Back to messages ]

gablea on 08/06/11 - 10:50:12

Hi everyone,

Just a quick question

how doI handle the keyboard in a QuickBasic applciation?

I am desgining a PoS application and I need to use given keys (example would be Shift & f1 for Sign on and right arrow for Sub Total)

does anyone know the BEST way to do this? I also need to handle the normal F1 - F12 and 0-9 keys etc

Andy

Cyperium on 08/06/11 - 11:08:50

You can get pretty far by using INKEY$



SCREEN 0, 0, 1, 0
DO
PCOPY 1, 0
CLS
PRINT "Press Right arrow or Shift + F1, ESC to end."
PRINT lastpress$
kbd$ = INKEY$
IF kbd$ = CHR$(0) + "M" THEN lastpress$ = "Right arrow"
IF kbd$ = CHR$(0) + CHR$(84) THEN lastpress$ = "Shift + F1"
LOOP UNTIL kbd$ = CHR$(27)



For the ASCII codes look here: ASCII - QB64 Wiki

gablea on 08/06/11 - 14:06:40

So if I wanted to support differnt keyboard but use the same program should I create a mapper program

is there some way to detect if the Chr$(0) is being sent or do I use

SCREEN 0, 0, 1, 0
DO
PCOPY 1, 0
CLS
PRINT "Press Right arrow or Shift + F1, ESC to end."
PRINT lastpress$
kbd$ = INKEY$
IF kbd$ = CHR(97) Then lastpress$ = "key a presseds"
IF kbd$ = CHR$(0) + "M" THEN lastpress$ = "Right arrow"
IF kbd$ = CHR$(0) + CHR$(84) THEN lastpress$ = "Shift + F1"
LOOP UNTIL kbd$ = CHR$(27)

gablea on 08/06/11 - 14:20:43

So if I wanted to support differnt keyboard but use the same program should I create a mapper program

is there some way to detect if the Chr$(0) is being sent or do I use

SCREEN 0, 0, 1, 0
DO
PCOPY 1, 0
CLS
PRINT "Press Right arrow or Shift + F1, ESC to end."
PRINT lastpress$
kbd$ = INKEY$
IF kbd$ = CHR(97) Then lastpress$ = "key a presseds"
IF kbd$ = CHR$(0) + "M" THEN lastpress$ = "Right arrow"
IF kbd$ = CHR$(0) + CHR$(84) THEN lastpress$ = "Shift + F1"
LOOP UNTIL kbd$ = CHR$(27)

Cyperium on 08/06/11 - 21:08:37

The same ASCII codes should apply to any keyboard configuration. I haven't yet seen any example when this isn't true (at least for the common ASCII codes).

ASCII is the standard. If there are problems with this - even so - then you can always have a detection system. Like:



SCREEN 0,0,1,0

DO
PCOPY 1,0
CLS
kb$ = INKEY$
LOCATE 1,1: PRINT "Press what you want to define as RIGHT."
LOCATE 2,1: PRINT "Press <RIGHT>"
LOOP UNTIL kb$ <> ""
IF kb$ = CHR$(27) THEN END
kbright$ = kb$
DO
PCOPY 1,0
CLS
LOCATE 1,1: PRINT "Press what you defined as RIGHT! :)"
kb$ = INKEY$
IF kb$ = kbright$ THEN inputted$ = "RIGHT!!!"
LOCATE 2,1: PRINT inputted$
LOOP UNTIL kb$ = chr$(27)



Cyperium on 08/06/11 - 21:09:17

lol

Cyperium on 08/06/11 - 21:10:31

Isn't this song just the best?

Smokie - I'll Meet You At Midnight

I've taken a few drinks tonight, hope you don't mind. ;)

Reply to this message
Name:
Message:
Please enter this number:
No HTML allowed. You may use BB-code in your posting.
Members
Login
Register
QB45 Members
Member List