code by Michael Avila,
written by Kirupa | 3 April 2006
If you frequent the
Source/Experiments forum, chances are that you have
run into Michael Avila's (MichalxxOA) experiments. This
tutorial is based on Michael's Multiple Key Detection
script, and by reading this tutorial, I hope you will learn
not only how Michael created the multiple key detection
functionality but also tips on how you can use it and modify
it for your own projects.
Whenever you use keyboard shortcuts, you are holding and
pressing several keys consecutively. Have you ever thought
about how this functionality actually works? What causes
your computer to realize that when you press the N key while
holding down the Ctrl key, you meant to type Ctrl + N as
opposed to each key separately?
While the answers to the above questions depend largely
on the implementation of the multiple key detection, the
overall idea behind them is the same - keep track of keys
pressed and check whether the pressed keys map to a valid
shortcut.
The following is an animation implementing the Multiple
Key Detection script you will learn about in this tutorial.
Click on the GO button in the animation below and press the
Ctrl + K keys to randomly keep displaying the letter K:
[ click GO in the above animation
and press Ctrl + K ]
Beyond explaining how to detect multiple keys, this
tutorial also covers the following high-level topics:
- Accessing Data stored in
Multidimensional Arrays
- Using Classes
- Understanding Somebody
Else's Code
If you are a beginning Flasher, this tutorial might be a
little complicated. Don't worry though, the following
tutorials on
Object Oriented
Programming and
Arrays should prepare you well for
what lies ahead in the following pages. I will also provide
enough tips and clarifications so that you won't be lost.
The tutorial is broken into the following sections:
- How to Use
- Code Explanation
- Conclusion
The following pages will take you through each of the
sections and hopefully teach you something that you might
not have known about before.
Onwards to the
next page!
|