Should I use the input class, or my own key listener?

MyLegGuy

Smashed Block
Member
Joined
Nov 30, 2015
Messages
3
Reaction score
6
First Language
English
Primarily Uses
N/A
Right now, I'm using a bunch of if statements in the update function to check for keys.


if (Input.isPressed("up")){
}else if (Input.isPressed("down")){
}else if (Input.isPressed("left")){
} else if (Input.isPressed("right")){
}


The problem is, sometimes a key is missed if I tap it too fast.


Would it be a okay if I added my own key listener instead of using the input class, or is that not okay?

Code:
document.addEventListener('keydown', somemethod);
 

Capitán

kind of a big deal
Veteran
Joined
Jul 9, 2013
Messages
572
Reaction score
145
First Language
Engilsh
Primarily Uses
RMMV
I don't foresee any issues.
 

astracat111

Astra Cat
Veteran
Joined
Jun 16, 2015
Messages
207
Reaction score
117
First Language
English
Primarily Uses
I use Input.isTriggered('right') { } etc... 


You use pages or states if you're just using coding. If you're using rpg maker mv eventing, you just use pages. 


somefunction.prototype.update {
if (page == 1) { set up, then page = 2 }
if (page == 2) { if (Input.isTriggered('ok') { page = 3 } }
if (page == 3 { process result }
}




Very easy, no problem with what's there, unless you need access to more keys, although that's what all of these amazing plugins that are already out are for. Depends though if you'd like to do it on your own, but you asked "do you think I would need to?" and I think the answer is no to that, you don't NEED to. You CAN if you want to practice programming. ; p
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,047
Members
137,569
Latest member
Shtelsky
Top