Revision history for KeyPgMultikey


Revision [20984]

Last edited on 2016-03-13 04:46:34 by fxm [Formatting]

No Differences

Revision [20331]

Edited on 2016-02-10 16:03:05 by DkLwikki [Update link format]
Additions:
[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Multikey** ( [[KeyPgByval|byval]] //scancode// [[KeyPgAs|as]] [[KeyPgLong|long]] ) [[KeyPgAs|as]] [[KeyPgLong|long]]
The [[GfxScancodes|scan code]] of the key to check.
Returns ##-1## if the key for the specified [[GfxScancodes|scan code]] is pressed, otherwise returns ##0##.
##**Multikey**## is a function which will detect the status of any key, determined by scancode, at any time. It will return ##-1## if the key is pressed, otherwise it will return ##0##. The keyboard input buffer is not disabled while you use ##**Multikey**##; that is, pressed keys will be stored and subsequently returned by your next call to ##[[KeyPgInkey|Inkey]]##. This means you have to empty ##[[KeyPgInkey|Inkey]]## manually when you finish using ##**Multikey**##, using something like the following method:
Keeping ##[[KeyPgInkey|Inkey]]## to work while you use ##**Multikey**## allows more flexibility and can be useful to detect ##[[KeyPgChr|Chr]](255)+"k"## combo returned on window close button click, if a windowed graphics mode has been set via the ##[[KeyPgScreengraphics|Screen]]## statement. For a list of accepted scancodes, see [[GfxScancodes|DOS keyboard scancodes]]; these are guaranteed to be valid for all ""FreeBASIC"" supported platforms.
##**Multikey**## should always work in graphics mode, as long as the screen is [[KeyPgScreenunlock|unlocked]]. Support in the console depends on the platform the program is run on though, and cannot be guaranteed.
' Clear the screen and draw a circle at the position (x, y)
Cls
Circle(x, y), 30, , , , ,F
- Not available in the //[[CompilerOptlang|-lang qb]]// dialect unless referenced with the alias ##**""__Multikey""**##.
- [[GfxScancodes|Keyboard scancodes]]
- ##[[KeyPgGetmouse|Getmouse]]##
- ##[[KeyPgGetjoystick|Getjoystick]]##
- ##[[KeyPgScreengraphics|Screen (Graphics)]]##
- ##[[KeyPgInkey|Inkey]]##
Deletions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Multikey** ( [[KeyPgByval byval]] //scancode// [[KeyPgAs as]] [[KeyPgLong long]] ) [[KeyPgAs as]] [[KeyPgLong long]]
The [[GfxScancodes scan code]] of the key to check.
Returns ##-1## if the key for the specified [[GfxScancodes scan code]] is pressed, otherwise returns ##0##.
##**Multikey**## is a function which will detect the status of any key, determined by scancode, at any time. It will return ##-1## if the key is pressed, otherwise it will return ##0##. The keyboard input buffer is not disabled while you use ##**Multikey**##; that is, pressed keys will be stored and subsequently returned by your next call to ##[[KeyPgInkey Inkey]]##. This means you have to empty ##[[KeyPgInkey Inkey]]## manually when you finish using ##**Multikey**##, using something like the following method:
Keeping ##[[KeyPgInkey Inkey]]## to work while you use ##**Multikey**## allows more flexibility and can be useful to detect ##[[KeyPgChr Chr]](255)+"k"## combo returned on window close button click, if a windowed graphics mode has been set via the ##[[KeyPgScreengraphics Screen]]## statement. For a list of accepted scancodes, see [[GfxScancodes DOS keyboard scancodes]]; these are guaranteed to be valid for all ""FreeBASIC"" supported platforms.
##**Multikey**## should always work in graphics mode, as long as the screen is [[KeyPgScreenunlock unlocked]]. Support in the console depends on the platform the program is run on though, and cannot be guaranteed.
' Clear the screen and draw a circle at the position (x, y)
Cls
Circle(x, y), 30, , , , ,F
- Not available in the //[[CompilerOptlang -lang qb]]// dialect unless referenced with the alias ##**""__Multikey""**##.
- [[GfxScancodes Keyboard scancodes]]
- ##[[KeyPgGetmouse Getmouse]]##
- ##[[KeyPgGetjoystick Getjoystick]]##
- ##[[KeyPgScreengraphics Screen (Graphics)]]##
- ##[[KeyPgInkey Inkey]]##


Revision [17522]

Edited on 2015-04-01 12:21:06 by DkLwikki [integer => long]
Additions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Multikey** ( [[KeyPgByval byval]] //scancode// [[KeyPgAs as]] [[KeyPgLong long]] ) [[KeyPgAs as]] [[KeyPgLong long]]
Deletions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Multikey** ( [[KeyPgByval byval]] //scancode// [[KeyPgAs as]] [[KeyPgInteger integer]] ) [[KeyPgAs as]] [[KeyPgInteger integer]]


Revision [15615]

Edited on 2012-01-08 03:40:38 by FxMwikki [Add 'Sleep 15, 1' in example, to slow the circle displacement according to the arrow keys pressed]
Additions:
Sleep 15, 1


Revision [13674]

Edited on 2008-09-01 19:22:20 by CountingPine [Mention FB namespace; misc edits]
Additions:
##**Multikey**## is a function which will detect the status of any key, determined by scancode, at any time. It will return ##-1## if the key is pressed, otherwise it will return ##0##. The keyboard input buffer is not disabled while you use ##**Multikey**##; that is, pressed keys will be stored and subsequently returned by your next call to ##[[KeyPgInkey Inkey]]##. This means you have to empty ##[[KeyPgInkey Inkey]]## manually when you finish using ##**Multikey**##, using something like the following method:
While Inkey <> "": Wend '' loop until the Inkey buffer is empty
Keeping ##[[KeyPgInkey Inkey]]## to work while you use ##**Multikey**## allows more flexibility and can be useful to detect ##[[KeyPgChr Chr]](255)+"k"## combo returned on window close button click, if a windowed graphics mode has been set via the ##[[KeyPgScreengraphics Screen]]## statement. For a list of accepted scancodes, see [[GfxScancodes DOS keyboard scancodes]]; these are guaranteed to be valid for all ""FreeBASIC"" supported platforms.
#if __fb_lang__ = "fb"
Using FB '' Scan code constants are stored in the FB namespace in lang FB
#endif
Dim As Integer x, y
Screenres 640, 480
Color 2, 15
x = 320: y = 240
Do
' Check arrow keys and update the (x, y) position accordingly
If MultiKey(SC_LEFT ) And x > 0 Then x = x - 1
If MultiKey(SC_RIGHT) And x < 639 Then x = x + 1
If MultiKey(SC_UP ) And y > 0 Then y = y - 1
If MultiKey(SC_DOWN ) And y < 479 Then y = y + 1

' Lock the page while we work on it
Screenlock
' Clear the screen and draw a circle at the position (x, y)
Cls
Circle(x, y), 30, , , , ,F
ScreenUnlock

' Run loop until user presses Escape
Loop Until MultiKey(SC_ESCAPE)
' Clear Inkey buffer
Print "Press CTRL and H to exit..."
Do
Sleep 25

'' Stay in loop until user holds down CTRL and H at the same time
If MultiKey(SC_CONTROL) And MultiKey(SC_H) Then Exit Do
Loop
- New to ""FreeBASIC""
Deletions:
##**Multikey**## is a function which will detect the status of any key, determined by scancode, at any time. It will return ##-1## if the key is pressed, otherwise it will return 0. The keyboard input buffer is not disabled while you use ##**Multikey**##; that is, pressed keys will be stored and subsequently returned by your next call to ##[[KeyPgInkey Inkey]]##. This means you have to empty ##[[KeyPgInkey Inkey]]## when you finish using ##**Multikey**##:
Keeping ##[[KeyPgInkey Inkey]]## to work while you use ##**Multikey**## allows more flexibility and can be useful to detect ##[[KeyPgChr Chr]](255)+"k"## combo returned on window close button click, if a windowed graphics mode has been set via the ##[[KeyPgScreengraphics Screen]]## statement. For a list of accepted scancodes, see [[GfxScancodes DOS keyboard scancodes]]; these are guaranteed to be valid for all FreeBASIC supported platforms.
DIM work_page AS INTEGER, x AS INTEGER, y AS INTEGER
' Request 640x480 with 2 pages
SCREEN 18, ,2
COLOR 2, 15
work_page = 0
x = 320
y = 240
DO
' Let's work on a page while we display the other one
SCREENSET work_page, work_page XOR 1
' Check arrow keys and update position accordingly
IF MULTIKEY(FB.SC_LEFT) AND x > 0 THEN x = x - 1
IF MULTIKEY(FB.SC_RIGHT) AND x < 639 THEN x = x + 1
IF MULTIKEY(FB.SC_UP) AND y > 0 THEN y = y - 1
IF MULTIKEY(FB.SC_DOWN) AND y < 479 THEN y = y + 1
CLS
CIRCLE(x, y), 30, , , , ,F
' Page flip
work_page = work_page XOR 1
LOOP WHILE NOT MULTIKEY(FB.SC_ESCAPE)
' Clear input buffer
WHILE INKEY = "": WEND
' Restore both work and visible pages to page 0
SCREENSET
PRINT "Press CTRL and H to exit..."
DO
SLEEP 25
IF MULTIKEY(FB.SC_CONTROL) AND MULTIKEY(FB.SC_H) THEN EXIT DO
LOOP
- New to FreeBASIC


Revision [13405]

The oldest known version of this page was created on 2008-05-31 14:04:34 by JeffMarshall [Mention FB namespace; misc edits]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode