Click here to Skip to main content
15,887,356 members
Home / Discussions / JavaScript
   

JavaScript

 
AnswerRe: Bug in try catch statement can I can't find where. Pin
Karthik_Mahalingam4-Oct-17 17:53
professionalKarthik_Mahalingam4-Oct-17 17:53 
AnswerRe: Bug in try catch statement can I can't find where. Pin
ZurdoDev11-Oct-17 9:48
professionalZurdoDev11-Oct-17 9:48 
AnswerRe: Bug in try catch statement can I can't find where. Pin
Weavr8-Apr-18 1:58
Weavr8-Apr-18 1:58 
QuestionJavascript Pin
Member 134419482-Oct-17 15:59
Member 134419482-Oct-17 15:59 
AnswerRe: Javascript Pin
Richard MacCutchan2-Oct-17 21:51
mveRichard MacCutchan2-Oct-17 21:51 
AnswerRe: Javascript Pin
GKP19923-Oct-17 23:52
professionalGKP19923-Oct-17 23:52 
AnswerRe: Javascript Pin
Karthik_Mahalingam4-Oct-17 17:51
professionalKarthik_Mahalingam4-Oct-17 17:51 
QuestionDocument.OnKeyDown Pin
Member 1342709424-Sep-17 10:58
Member 1342709424-Sep-17 10:58 
Hey guys!

Im in a bit of a pickle.

Im supposed to hand in an assignment where i will use the arrows on the keyboard to make a rectangle move.

I cant figure out how to do it. My teacher wont respond to my messages. Im hoping you guys can help me or point me in the right direction. Code is included below.

Thanks!

window.onload=function() {
var canvas=document.getElementById('myCanvas');
context= canvas.getContext('2d');

context.fillStyle="#FF0000";
context.fillRect(0,0,75,50);


var rect=new Object();
rect.x=0;
rect.y=0;
rect.moveright=function(){rect.x++;}
rect.draw=function(){

rect.x
rect.y
}

document.onkeydown=function(e){
if(e.keyCode=="39"){
rect.erase();
rect.moveright();
rect.draw();

}
if(e.keyCode=="37"){
rect.erase();
rect.moveleft();
rect.draw();


}

if(e.keyCode=="40"){
rect.erase();
rect.movedown();
rect.draw();
}

if(e.keyCode=="38"){
rect.erase();
rect.moveup();
rect.draw();

}


}


};
QuestionRe: Document.OnKeyDown Pin
ZurdoDev2-Oct-17 3:11
professionalZurdoDev2-Oct-17 3:11 
AnswerRe: Document.OnKeyDown Pin
Richard MacCutchan2-Oct-17 6:01
mveRichard MacCutchan2-Oct-17 6:01 
QuestionHow to upgrade apps from angular 1 to angular 4 Pin
GKP199220-Sep-17 22:15
professionalGKP199220-Sep-17 22:15 
AnswerRe: How to upgrade apps from angular 1 to angular 4 Pin
Nathan Minier2-Oct-17 1:54
professionalNathan Minier2-Oct-17 1:54 
GeneralRe: How to upgrade apps from angular 1 to angular 4 Pin
GKP19923-Oct-17 23:50
professionalGKP19923-Oct-17 23:50 
QuestionJavascript inner function,to which object does an inner functions belongs to Pin
Member 1335414214-Sep-17 21:16
Member 1335414214-Sep-17 21:16 
AnswerRe: Javascript inner function,to which object does an inner functions belongs to Pin
Mohibur Rashid20-Sep-17 22:45
professionalMohibur Rashid20-Sep-17 22:45 
GeneralAn Alternative To Confirm Pin
mahfuzz12-Sep-17 1:59
mahfuzz12-Sep-17 1:59 
QuestionRe: An Alternative To Confirm Pin
ZurdoDev12-Sep-17 3:35
professionalZurdoDev12-Sep-17 3:35 
Questiondatabase connection Pin
Member 133907602-Sep-17 17:00
Member 133907602-Sep-17 17:00 
AnswerRe: database connection Pin
Mycroft Holmes2-Sep-17 22:40
professionalMycroft Holmes2-Sep-17 22:40 
SuggestionRe: database connection Pin
ZurdoDev12-Sep-17 1:28
professionalZurdoDev12-Sep-17 1:28 
QuestionRe: database connection Pin
ZurdoDev12-Sep-17 1:29
professionalZurdoDev12-Sep-17 1:29 
Questionjava script Pin
Mehrnaz-Pi24-Aug-17 6:42
Mehrnaz-Pi24-Aug-17 6:42 
AnswerRe: java script Pin
Richard Deeming24-Aug-17 7:53
mveRichard Deeming24-Aug-17 7:53 
GeneralRe: java script Pin
Mehrnaz-Pi24-Aug-17 22:29
Mehrnaz-Pi24-Aug-17 22:29 
QuestionI want to make bat file to run my .jar file withot jdk or jre in the pc Pin
Member 1335949322-Aug-17 10:20
Member 1335949322-Aug-17 10:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.