Khan / Khan/live-editor

Challenge keyCode steps are not that good.

Open
#469 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
776
Forks
180
PR merge metrics
No merged PRs in 30d

Description

A few days back I was scrolling through the challenges of Advanced JS: Natural Simulations and I noticed that in one of the challenges, the way `keyPressed` was organized is horrible.

In Challenge: Turning car, the user has to write the following for Step 1:

```
keyPressed = function(){}
if(keyCode === LEFT){
car.turnLeft();
} else if(keyCode === RIGHT){
car.turnRight();
}
```

The following system usually works, but sometimes glitches out. I think that we should create a better method for this. User @DillingerLee on Khan Academy has done so like this:

```
var keys = [];
keyPressed = function(){
keys[keyCode] = true;
};

keyReleased = function(){
delete keys[keyCode];
};
```

Then in the draw function, instead of `if(keyIsPressed && keyCode ===` or `if(keyCode ===`, we would have `if(keys[]` for less glitchier issues.

Contributor guide

No contributing guide indexed for this repository

Research direction

Locate the Advanced JS: Natural Simulations content for the “Turning car” challenge and review its current keyCode steps. Compare the existing keyPressed example with the proposed key-tracking approach, then verify that the challenge instructions consistently describe the intended handling and avoid the reported glitches.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
content
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.