misc >> FreeBASIC: detect Shift-press

by Bughunter » Mon, 08 Jan 2007 07:45:16 GMT

Detecting only Shift-pressing in a program? Alt and Ctrl too.
I use the DOS version.

--
Bughunter

misc >> FreeBASIC: detect Shift-press

by Gordon Rahman » Fri, 12 Jan 2007 23:01:50 GMT


And?
Succeeded? with the DOS version?

Do you want to try Just BASIC? That's free too.

'- how to use the Inkey$ variable to detect SHIFT

open "Inkey$ example" for graphics as #graph
#graph, "when characterInput [fetch]"


#graph, "setfocus"
WAIT

[fetch] 'a character was typed!

key$ = Inkey$

keyValue = asc(right$(key$, 1))
if keyValue = _VK_SHIFT then
notice "Shift was pressed"
else
notice "You pressed something else"
end if
WAIT

Gordon


"Bughunter" < XXXX@XXXXX.COM > schreef in bericht

misc >> FreeBASIC: detect Shift-press

by Juergen Bors » Tue, 16 Jan 2007 05:34:32 GMT

Am 2007-01-08 schrieb Bughunter:


If you only use a DOS window, try this code:

(freebasic 0.16)

---8<-------
#include once "windows.bi"

do

If GetAsyncKeyState(16) < 0 then print "SHIFT key pressed"
If GetAsyncKeyState(17) < 0 then print "CTRL key pressed"
If GetAsyncKeyState(18) < 0 then print "ALT key pressed"
sleep 50 'only to make it slower

loop until GetAsyncKeyState(13) < 0 'Return will stop the loop

sleep
---8<-------


See also: http://www.activevb.de/tipps/vb6tipps/tipp0070.html

--
Mit freundlichen Gren

Jgen Bors
---