Challenge keyCode steps are not that good.
- 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