The Daily Click ::. Forums ::. Klik Coding Help ::. Read what key is pressed down on keyboard
 

Post Reply  Post Oekaki 
 

Posted By Message

eski



Registered
  20/09/2009
Points
  39
23rd February, 2011 at 23:18:02 -

It has been some time since I used MMF and I'm kinda rusty.

My goal is to make a simple game where some words fly at you and you have to type them so they get destroyed.
I don't know what is the best way to do this but first things first, how can i find out what key has been pressed on the keyboard ?

Any suggestions or hints on making this are well accepted.

 
n/a

s-m-r

Slow-Motion Riot

Registered
  04/06/2006
Points
  1078

Candle
24th February, 2011 at 17:42:13 -

The event you're looking for most likely would be under the "mouse and keyboard" category.

Look for "upon pressing a key," and when required to input a keystroke, press the corresponding letter/key on your keyboard. The event then shows up in the Editor as:

///

Upon pressing [the key you just pressed]

///

Although I've never tried to make a typing program, my assumption is that you'll need an event similar to this for each key pressed in the Event Editor an event in your Event Editor for each key pressed and/or used in your program. These can also be Negated, which means that there will be a big red "X" next to the event indicating the Event's opposite. So then, it could be translated to:

///

When the [key] is not pressed

///

Good luck on your project.

Edited by s-m-r

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
24th February, 2011 at 18:07:03 -

The easiest way is probably to just have a hidden edit box, and an always event to ensure it keeps the input focus.

eg.

+ always
-> Edit Box: get focus

+ *whenever*
-> Set Answer to *whatever*
-> Set Edittext$( "Edit Box" ) to ""

+ Edittext$( "Edit Box" ) = Answer
-> correct answer!

+ if Len( Edittext$( "Edit Box" ) = Len( Answer )
+ if Edittext$( "Edit Box" ) <> Answer
-> wrong answer!

Something like that?
You might want to change it a bit - maybe use right$(string,#chars) to get just the most recently typed characters.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click