Downkey
State = Downkey()
 
Parameters: NONE
Returns:

    State = The sate of the key (0= up, 1 = pressed)
 

      The DownKey() function with return the state of DOWN ARROW key on your keyboard.

      Since the Arrows keys are commonly used as game controls, these keys have their own special commands. Purely to make things easier to remember.

      If the key is being pressed this function will return a value of 1 (True), however if it's not being pressed, it will return a zero (False.



FACTS:


      * None



Mini Tutorial #1:


      This example shows how to read the four arrow keys.

  
  
  Do
     Cls RGB(0,0,0)
     
   ; Display the Status of the UP,DOWN LEFT & RIGHT
   ; Arrow keys
     
     Print "Up Arrow Key State:"+Str$(UpKey())
     Print "Right Arrow Key State:"+Str$(RightKey())
     Print "Down Arrow Key State:"+Str$(DownKey())
     Print "Left Arrow Key State:"+Str$(LeftKey())
     
   ; Display the Screen and wait for the user to press a key
     Sync
  Loop
  
  





Mini Tutorial #2:


This example shows how to use arrow keys to control a character. In this case the character is a "circle", but the same basic logic applies to controlling a sprites or an image.


  
  
; Make the Variable XPOS = to the screen width divided by
; two.  So it should be in the center of the screen
  XPOS = GetScreenWidth()/2
  
; Make the Variable YPOS = to the screen width divided by
; two.  So it should be in the center of the screen
  YPOS = GetScreenHeight()/2
  
; Set the SPEED value to how fast the  object should move
  Speed=5
  
  Do
   ; Clear the Screen to BLACK (rgb(0,0,0)
     Cls RGB(0,0,0)
     
   ; If the User Presses the LEFT arrow, SUB speed
   ; from the XPOS variable
     If LeftKey()=1 Then Xpos=Xpos-Speed
     
   ; If the User Presses the RIGHTarrow, ADD speed
   ; to the XPOS variable
     If RightKey()=1 Then Xpos=Xpos+Speed
     
   ; If the User Presses the UP arrow, SUB speed
   ; from the YPOS variable
     If UpKey()=1 Then Ypos=Ypos-Speed
     
   ; If the User Presses the DOWN arrow, ADD speed
   ; to the YPOS variable
     If DownKey()=1 Then Ypos=Ypos+Speed
     
   ; Draw a Circle to represent the character your controlling
     Circle Xpos,Ypos,25,1
     
     
   ; Display the Screen and loop back to the DO statement
     Sync
  Loop
  
  



 
Related Info: ALtKeys | CtrlKeys | EnterKey | Leftkey | Mouse | MouseButton | Rightkey | Scancode | ShiftKeys | Spacekey | Upkey :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com