# Phaser Shooting Game [closed]

I am making an shooting game in Phaser. I want to control the gun using the arrow keys i.e.: upArrow, DownArrow and Enter

upArrow : is to increase the angle
downArrow : is to decrease the angle
Enter : To hit the target

I do not know, how to do this thing?

## closed as off-topic by Kromster, congusbongus, Alexandre Vaillancourt♦, Maximus Minimus, AnkoFeb 12 '17 at 14:10

• This question does not appear to be about game development within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

• Is this a problem capturing the input or implementing the behaviour? – Theraot Feb 6 '17 at 19:54
• Hello I am learning phaser so I need the sample code for this condition – kumaresh Feb 7 '17 at 5:23
• This doesn't seem like a specific game dev question. Instead it reads more like a request for others to write code for you. – Pikalek Feb 7 '17 at 7:53

I know very little about Phaser, but for my pure JS/canvas projects I handle key input with eventListeners. Here is how I do it:

var keys = {up:false, left:false, down:false, right:false};
//Add one for every key you want
//Change canvas to the active element
switch(e.keyCode){
case 38: //38 is keyCode for up arrow
keys.up=true;
break;
case 37: //37 is keyCode for left arrow
keys.left=true;
break;
//And so on... (No default needed)
}
}
switch(e.keyCode){
case 38:
keys.up=false;
break;
case 37:
keys.left=false;
break;
//And so on... (No default needed here either)
}
}
function gameLoop (){
//Now you can check if the key is pressed or not
if(keys.up){
player.moveUp(); //Or whatever you use for moving
}
if(keys.left){
player.moveLeft();
}
}


I have seen similar solutions, but with an array to save the key presses. To get the keyCodes, I would reccommend using keycode.info.

I hope this helps! (Maybe there is a much simpler way to do it with Phaser)