BreakKey
BreakKey Flag
 
Parameters:

    Flag = 1 will enable the ESC key as the program break, 0 to disable it
Returns: NONE
 

      BreakKey enables or disables the built in exit on ESCape feature.



FACTS:


      * By default the BreakKey is enabled. If you choose to turn Break key off, this will also disable the programs close button. (see: GetScreenClose )


      * It's highly recommended (during development of your programs) that you leave the break key enabled, so you can quickly exit your programs back to the editor. However in your final game, it's recommended that you disable the break and monitor it's state. So then you can trap when the player wants to quit and then exit gracefully! Perhaps taking them back to the menu, Let them save their score or whatever.




Mini Tutorial:


      This example lets the user toggle the BreakKey control on/off while the program is running. You should notice that when BreakKey is off, hitting the ESC key has no effect upon the running program. While hitting ESC while Break is ON, will quit the program as normal.


  
; ==================
; BreakKey Example
; ==================
  
;Tell PB to limit the speed of this program
  SetFPS 60
  
  Do
   ;Clear the screen
     Cls RGB(0,0,0)
     
   ;Check if the Break Key is ON/OFF
     If GetBreakKey()=on
        s$="ON  - pressing ESC key will quit this program"
     Else
        s$="OFF - Pressing ESC has no effect"
     EndIf
     
   ; Locate the center of the screen
     cx=GetScreenWidth()/2
     cy=(GetScreenHeight()/2)-20
     
   ; Display the current status of the break key
     CenterText cx,cy,"Break Key Current Status:"+s$
   ; display the instructions
     CenterText cx,cy+30,"Press Enter To Change BreakKey Status"
     
   ; Check if the Enter Key was pressed ?
     If EnterKey()=true
        BreakKey 1-GetBreakKey()
        FlushKeys
     EndIf
     
   ; Refresh the display so the user can see it
     Sync
  Loop
  




 
Related Info: GetBreakKey | GetScreenClose :
 


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