Giter Club home page Giter Club logo

scripted-event-handlers-lesson's Introduction

Event Handlers

Today we're going to draw. But better than that, we're going to have a drawing competition. But first we have to prepare our canvas to our awesome drawings.

In this project you have a few files:

  • index.html
  • js/index.js
  • js/tiny-turtle/
  • js/listeners.js

Where To Do Your Work

You will do all your work in js/listeners.js. In this file you will need to complete the following steps:

  1. Create an event listener on the document to listen for the keydown event
  2. Test which key has been pressed using event.keyCode
  3. Decide which controls you want to use (arrow keys are the easiest) and create your event handlers
  4. Make an event listener and event handler for the "Clear" button
  5. Draw an awesome picture

How Do I Make A Drawing?

After you create your event listeners and event handlers, you'll be able to call a few functions to make the drawing. Here are all the functions:

  • Turtle.forward()
    • This moves the line forward 5px
  • Turtle.right()
    • This rotates the line direction 10 degrees to the right
  • Turtle.left()
    • This rotates the line direction 10 degrees to the left
  • Turtle.clear()
    • This will erase the image and setup the line for a new drawing

IMPORTANT: There's no 'undo' functionality :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.