P5 Python Docs
  • Getting Started
  • Simple mode
  • Reference
    • Shapes
      • 2D
        • point()
        • line()
        • rect()
        • square()
        • triangle()
        • circle()
        • ellipse()
        • arc()
        • quad()
        • beginShape()
      • 3D
        • plane()
        • box()
        • sphere()
        • cone()
        • cylinder()
        • ellipsoid()
        • torus()
    • Controlling the environment
      • coordinateMode()
      • rectMode()
      • ellipseMode()
      • frameRate()
      • setup()
      • draw()
    • Built-in Variables
      • Environment
      • Keyboard
      • Mouse
    • Built-in Functions
      • keyIsDown()
      • millis()
      • second()
      • minute()
      • hour()
      • translate()
      • rotate()
      • createSlider()
      • createGraphics()
      • createVector()
    • Events
      • Keyboard
        • keyPressed()
        • keyReleased()
      • Mouse
        • mouseMoved()
        • mouseDragged()
        • mousePressed()
        • doubleClicked()
        • mouseWheel()
    • Text
      • text()
      • textSize()
      • textAlign()
    • Math
      • drawTickAxes()
      • random()
      • randomGaussian()
      • dist()
      • linmap()
      • bounce()
      • wave()
    • Colour and Outline
      • colorMode()
      • fill()
      • stroke()
      • strokeWeight()
      • background()
    • Images & Audio
      • loadImage() and image()
      • loadSound()
    • 3D Controls
      • orbitControl()
      • translate()
      • rotateZ()
      • rotateX()
      • rotateY()
      • scale()
Powered by GitBook
On this page
  • key
  • keyIsPressed
  • keyCode
  1. Reference
  2. Built-in Variables

Keyboard

These built-in variables will give you information about the keyboard.

PreviousEnvironmentNextMouse

Last updated 2 years ago

key

This built-in variable stores the value of the most recently pressed key. For example, if the user presses 'm', then 'b' :

key will be equal to 'b'

keyIsPressed

This built-in variable has the value True if any key is pressed at the moment. It has the value False otherwise. (Boolean datatype)

keyCode

This built-in variable stores the key code of the last key that was pressed.

Here are some built-in constants that can be used

ENTER = 13
SHIFT = 16
UP_ARROW = 38
DOWN_ARROW = 40
LEFT_ARROW = 37
RIGHT_ARROW = 39

In general, you can search the web for: key code of ### or look at .

Find these documents helpful? Let the people who made them help your child learn to code at !

We'd love to hear your Feedback/Comments .

this website
Strivemath
here