Pardon the mess, Play My Code is in beta!

READY TO PLAY?
CLICK TO LOG IN!

sign up - lost password

Keys Down or Pressed »

You do not own this project, so changes will not be saved

/* 
 * This is example code to help you get started
 * writing a new project.
 *
 * Edit this file and then click the run icon above.
 * Visit playmycode.com/docs if you need some help.
 * Don't forget to save your work!
 */

setFont( 'Arial', 32 )

minY = 45
leftY = 160
y = minY
inc = 60

// The code inside this do block is run each frame
onEachFrame() do
    fill( :pink, 0.1 )
    
    down = getControls().getKeysDown()
    pressed = getControls().getKeysPressed()
    
    setColor( :white ) do
        setFont( 'Arial', 32 ) do
            fillText( "Keys Down", 10, 10, :left, :top )
            fillText( "Keys Pressed", getScreenWidth()-10, 10, :right, :top )
            drawLine( 3, 41, getScreenWidth()-3, 41 )
        end
        
        setFont( 'Arial', 60 ) do
            // draw keys down
            fillText( down.join('\n'), leftY, minY, :center, :top )
            
            // draw keys pressed
            pressed.each() do |key|
                fillText( key, getScreenWidth()-leftY, y, :center, :top )
                y = (y + inc).wrap( minY, getScreenHeight() )
            end
        end
    end
end

ERRORS

YOUR BROWSER DOES NOT SUPPORT HTML5!

Please use one of these instead

Our games cannot run in your browser