Search JS code (of Worlds)

Search JavaScript code of all Worlds for: keycode


Touch World
301 runs ♦ 1 like
By Starter user  
Created: 6 Jan 2018
Modified: 12 Dec 2019
How to override default touch handling. Mobile: Touch drag moves agent, touch pinch zooms camera...
function ourKeys ( event ) { return ( OURKEYS.includes ( event.keyCode ) ); }
if ( event.keyCode == 37 ) moveLogicalAgent ( ACTION_LEFT );
if ( event.keyCode == 38 ) moveLogicalAgent ( ACTION_DOWN );
if ( event.keyCode == 39 ) moveLogicalAgent ( ACTION_RIGHT );
if ( event.keyCode == 40 ) moveLogicalAgent ( ACTION_UP );
User-controlled ...
443 runs ♦ 2 likes
By Starter user  
Created: 12 Feb 2017
Modified: 12 Dec 2019
3d model World. User controlled on desktop. Keyboard arrows to move. Switch to "Move with" camer...
function ourKeys ( event ) { return ( OURKEYS.includes ( event.keyCode ) ); }
if ( event.keyCode == KEY_UP ) // move a bit along angle we are facing
if ( event.keyCode == KEY_LEFT ) // rotate in place
if ( event.keyCode == KEY_RIGHT )
Infinite World G...
70 runs ♦ 0 likes
By Enhanced  
Created: 16 Aug 2018
Modified: 16 Aug 2018
Here is a code to get an infinite world that loop without object in it, and with the sun
if((e.keyCode == 38) || (e.keyCode == 40))
if(e.keyCode == 37 || e.keyCode == 39)
if(e.keyCode == 37 || e.keyCode == 39)
switch ( event.keyCode ) {
switch( event.keyCode ) {
MineCraft
635 runs ♦ 2 likes
By Starter user  
Created: 27 Nov 2016
Modified: 12 Dec 2019
Use keyboard to draw blocks like in MineCraft. Use arrow keys and PgUp, PgDn to draw. Can save w...
function ourKeys ( event ) { return ( OURKEYS.includes ( event.keyCode ) ); }
if ( event.keyCode == 37 ) theobject.position.x = cx - objectsize ; // left
if ( event.keyCode == 39 ) theobject.position.x = cx + objectsize ; // right
if ( event.keyCode == 38 ) theobject.position.z = cz - objectsize ; // forward
if ( event.keyCode == 40 ) theobject.position.z = cz + objectsize ; // back
if ( event.keyCode == 34 ) theobject.position.y = cy - objectsize ;
if ( event.keyCode == 33 ) theobject.position.y = cy + objectsize ;
Zombie Death Baby
426 runs ♦ 0 likes
By Starter user  
Created: 11 Jun 2018
Modified: 12 Dec 2019
How to make a fun touch game for mobile. Touch drag and tap objects. Mouse drag and click object...
function ourKeys ( event ) { return ( OURKEYS.includes ( event.keyCode ) ); }
if ( event.keyCode == 37 ) moveAgent ( ACTION_LEFT );
if ( event.keyCode == 38 ) moveAgent ( ACTION_DOWN );
if ( event.keyCode == 39 ) moveAgent ( ACTION_RIGHT );
if ( event.keyCode == 40 ) moveAgent ( ACTION_UP );
Enhanced Don't Move
68 runs ♦ 0 likes
By Enhanced  
Created: 12 Jun 2018
Modified: 27 Jun 2018
Try to dodge cubes as they fall to the ground, in this simple but efficient game
var code = event.keyCode;
Interstellar cubes
326 runs ♦ 3 likes
By Thomas Mc Cann  
Created: 16 Oct 2019
Modified: 3 Nov 2019
A journey into Interstellar space. Run and press F12 (in chrome) to view the console. Try left c...
var key = event.which || event.keyCode; // Use either which or keyCode, depending on browser support
Shooting Range
106 runs ♦ 0 likes
By Enhanced  
Created: 13 Jun 2018
Modified: 21 Jun 2018
Shoot the ducks, feel the spirit of the hunt. Enhanced version of "Shooting Range (Space To Shoo...
if (e.keyCode == 37) moveLogicalAgent( ACTION_LEFT );
if (e.keyCode == 38) moveLogicalAgent( ACTION_DOWN );
if (e.keyCode == 39) moveLogicalAgent( ACTION_RIGHT );
if (e.keyCode == 40) moveLogicalAgent( ACTION_UP );
if (e.keyCode == 32) // if the keycode is space.
Pacman
130 runs ♦ 0 likes
By Enhanced  
Created: 21 Jun 2018
Modified: 17 Aug 2018
Enhanced version of Game Pacman in Space, you need to collect all white bullet to end the game, ...
if (e.keyCode == 37) moveLogicalAgent ( ACTION_LEFT );
if (e.keyCode == 38) moveLogicalAgent ( ACTION_DOWN );
if (e.keyCode == 39) moveLogicalAgent ( ACTION_RIGHT );
if (e.keyCode == 40) moveLogicalAgent ( ACTION_UP );
Design Your Own ...
4307 runs ♦ 0 likes
By Jack O'Connor  
Created: 18 Feb 2019
Modified: 12 Mar 2019
Design Your Own Room Escape Game
if (keyCode === LEFT_ARROW)
else if (keyCode === RIGHT_ARROW)
if (keyCode === DOWN_ARROW && deg == 360)
Final Pool
815 runs ♦ 2 likes
By Ian Gilligan  
Created: 1 Mar 2019
Modified: 13 Aug 2019
Pool Predictor for CA326
function ourKeys(event) {return(OURKEYS.includes(event.keyCode));}
if ( event.keyCode == 49 ) {selectBall(0);}
else if ( event.keyCode == 50 ) {selectBall(1);}
else if ( event.keyCode == 51 ) {selectBall(2);}
else if ( event.keyCode == 52 ) {selectBall(3);}
Enhanced Space Pong
140 runs ♦ 0 likes
By Enhanced  
Created: 18 Jun 2018
Modified: 10 May 2019
It's all you want from Pong : smooth controls, different difficulty levels and game modes
if (e.keyCode == 37) player.movement = -1;
if (e.keyCode == 39) player.movement = 1;
if (e.keyCode == 37 && player.movement == -1) player.movement = 0;
else if (e.keyCode == 39 && player.movement == 1) player.movement = 0;
Romantic Sunset
100 runs ♦ 0 likes
By Enhanced  
Created: 17 Aug 2018
Modified: 10 May 2019
Turn your head and discover a eautiful scenery observable in first person mode.
switch ( event.keyCode ) {
switch( event.keyCode ) {
Capture The Egg
38 runs ♦ 0 likes
By tuitef2  
Created: 8 Mar 2019
Modified: 11 Mar 2019
keyboard[event.keyCode] = true;
keyboard[event.keyCode] = false;
Rythm of the night
134 runs ♦ 0 likes
By Enhanced  
Created: 2 Aug 2018
Modified: 2 Aug 2018
A rythm game where you have to use the right inputs at the right time to progress from one level...
//it can take the values 38 to 41. The html keycode of the arrow keys goes
if (e.keyCode == 37 || e.keyCode == 38 || e.keyCode == 39 || e.keyCode == 40)
if (actionRequired !== undefined && e.keyCode == obstacles[actionRequired])
//by the keycode of that arrow)(70% of the time) either nothing (represented
Complete Infinit...
320 runs ♦ 0 likes
By Enhanced  
Created: 9 Aug 2018
Modified: 26 Aug 2018
This program was made by Nathan Bonnard. In this world, you can generate an infinite world ! Bu...
if((e.keyCode == 38) || (e.keyCode == 40))
if(e.keyCode == 37 || e.keyCode == 39)
if(e.keyCode == 37 || e.keyCode == 39)
switch ( event.keyCode ) {
switch( event.keyCode ) {
Game of Crowns s...
108 runs ♦ 0 likes
By Enhanced  
Created: 21 Jun 2018
Modified: 27 Aug 2018
Enhanced version of "Game of Crowns" by Niamh Byrne with better graphics and controls
var code = a.keyCode;
if (e.keyCode == 37) { moveLogicalAgent ( ACTION_LEFT ); e.preventDefault(); }
if (e.keyCode == 40) { moveLogicalAgent ( ACTION_DOWN ); e.preventDefault(); }
if (e.keyCode == 39) { moveLogicalAgent ( ACTION_RIGHT ); e.preventDefault(); }
if (e.keyCode == 38) { moveLogicalAgent ( ACTION_UP ); e.preventDefault(); }
Catch the flag
4194 runs ♦ 1 like
By Meabh Horan  
Created: 16 Nov 2016
Modified: 10 Feb 2018
if (e.keyCode == 37) moveLogicalAgent ( ACTION_LEFT );
if (e.keyCode == 38) moveLogicalAgent ( ACTION_DOWN );
if (e.keyCode == 39) moveLogicalAgent ( ACTION_RIGHT );
if (e.keyCode == 40) moveLogicalAgent ( ACTION_UP );
if (e.keyCode == 32) moveLogicalAgent ( ACTION_JUMPFORWARD); //cheat code to jump
Game of Crowns
1735 runs ♦ 2 likes
By Niamh Byrne  
Created: 16 Nov 2016
Modified: 10 Feb 2018
var code = a.keyCode;
if (e.keyCode == 37) { moveLogicalAgent ( ACTION_LEFT ); e.preventDefault(); }
if (e.keyCode == 38) { moveLogicalAgent ( ACTION_DOWN ); e.preventDefault(); }
if (e.keyCode == 39) { moveLogicalAgent ( ACTION_RIGHT ); e.preventDefault(); }
if (e.keyCode == 40) { moveLogicalAgent ( ACTION_UP ); e.preventDefault(); }
Election - AI Ve...
1891 runs ♦ 3 likes
By Ross Franey  
Created: 22 Oct 2016
Modified: 10 Feb 2018
if (e.keyCode == 37) moveLogicalAgent ( ACTION_LEFT );
if (e.keyCode == 38) moveLogicalAgent ( ACTION_DOWN );
if (e.keyCode == 39) moveLogicalAgent ( ACTION_RIGHT );
if (e.keyCode == 40) moveLogicalAgent ( ACTION_UP );
if (e.keyCode == 32) ai = randomintAtoB(1,gridsize-2), aj = randomintAtoB(1,gridsize-2);
Pacman In Space
1503 runs ♦ 0 likes
By Simon Lowry  
Created: 16 Nov 2016
Modified: 10 Feb 2018
if (e.keyCode == 37) moveLogicalAgent ( ACTION_LEFT );
if (e.keyCode == 38) moveLogicalAgent ( ACTION_DOWN );
if (e.keyCode == 39) moveLogicalAgent ( ACTION_RIGHT );
if (e.keyCode == 40) moveLogicalAgent ( ACTION_UP );
Spider Paradise ...
660 runs ♦ 2 likes
By Aisling Casserly  
Created: 8 Dec 2016
Modified: 10 Feb 2018
if (e.keyCode == 37) moveLogicalAgent ( ACTION_LEFT );
if (e.keyCode == 38) moveLogicalAgent ( ACTION_DOWN );
if (e.keyCode == 39) moveLogicalAgent ( ACTION_RIGHT );
if (e.keyCode == 40) moveLogicalAgent ( ACTION_UP );
if (e.keyCode == 65) moveLogicalAgent ( JUMP_LEFT );
if (e.keyCode == 87) moveLogicalAgent ( JUMP_DOWN );
if (e.keyCode == 68) moveLogicalAgent ( JUMP_RIGHT );
if (e.keyCode == 88) moveLogicalAgent ( JUMP_UP );
FLESHMAN PLAYS G...
4402 runs ♦ 2 likes
By Sean Hutchinson  
Created: 21 Oct 2016
Modified: 10 Feb 2018
if (e.keyCode == 37) // left
if (e.keyCode == 39) // right
if (e.keyCode == 38) // down
if (e.keyCode == 40) // up
if (e.keyCode == 97) // numpad1 is putt
if (e.keyCode == 98) // numpad2 is shot
if (e.keyCode == 99) // numpad3 is drive
Don't Move
1187 runs ♦ 1 like
By Finnian O'Neill  
Created: 6 Dec 2016
Modified: 10 Feb 2018
var code = event.keyCode;
Super Mario Maze
1945 runs ♦ 4 likes
By Cathal Neary  
Created: 19 Nov 2016
Modified: 10 Feb 2018
if (e.keyCode == 37) { moveLogicalAgent ( ACTION_LEFT ); e.preventDefault(); }
if (e.keyCode == 38) { moveLogicalAgent ( ACTION_DOWN ); e.preventDefault(); }
if (e.keyCode == 39) { moveLogicalAgent ( ACTION_RIGHT ); e.preventDefault(); }
if (e.keyCode == 40) { moveLogicalAgent ( ACTION_UP ); e.preventDefault(); }
if (e.keyCode == 32) { moveLogicalAgent ( ACTION_JUMP ); e.preventDefault(); }
Shooting Range (...
2201 runs ♦ 4 likes
By Adrian Rabbitte  
Created: 16 Nov 2016
Modified: 10 Feb 2018
if (e.keyCode == 37) moveLogicalAgent ( ACTION_LEFT );
if (e.keyCode == 38) moveLogicalAgent ( ACTION_DOWN );
if (e.keyCode == 39) moveLogicalAgent ( ACTION_RIGHT );
if (e.keyCode == 40) moveLogicalAgent ( ACTION_UP );
if (e.keyCode == 32) // if the keycode is space.
Space Plane Shooter
575 runs ♦ 2 likes
By Brian Kilduff  
Created: 26 Nov 2016
Modified: 10 Feb 2018
if (e.keyCode == 37) moveLogicalAgent ( ACTION_LEFT ); //left arrow key
if (e.keyCode == 38 && jump1 == false) //up arrow key
if (e.keyCode == 39) moveLogicalAgent ( ACTION_RIGHT ); //right arrow key
if (e.keyCode == 66) moveLogicalAgent ( ACTION_DOWN ); //"b"key
if (e.keyCode == 32) //speace bar key fires bullets
Looney Tunes Cha...
1261 runs ♦ 2 likes
By Sean Sinnott  
Created: 16 Nov 2016
Modified: 10 Feb 2018
if (e.keyCode == 37)
if (e.keyCode == 38)
if (e.keyCode == 39)
if (e.keyCode == 40)
if (e.keyCode == 83)
Globe Trotter
1352 runs ♦ 2 likes
By Laura Araviciute  
Created: 3 Dec 2016
Modified: 10 Feb 2018
var code = event.keyCode;
Coding Challenge 3
14 runs ♦ 0 likes
By "Coding Train" p...  
Created: 4 Sep 2018
Modified: 4 Sep 2018
The Snake Game
if (keyCode === UP_ARROW) {
} else if (keyCode === DOWN_ARROW) {
} else if (keyCode === RIGHT_ARROW) {
} else if (keyCode === LEFT_ARROW) {


The background is a program, showing the JavaScript graphics used on this site.
The globes light up when you log in.
 
Font:

© Ancient Brain Ltd. 2018-19. All rights reserved.

Ancient Brain ™ is a trademark of Ancient Brain Ltd.

Platforms      Stats      The name      Terms and conditions

Bug bounty      Classes in Dublin      Contact

Call for partners!
If you are interested in writing a programming course or textbook, Ancient Brain is looking for partners. We will work with you, and integrate your course into the site. This is an opportunity for someone looking to develop a course or textbook to partner with a site to support it and promote it.