I use the following analogy to describe the scripts/events system in WME: the game comprises of lots of game objects: scene, entities, actors, GUI windows and others. Each of these objects can have one or more scripts attached to it, which works as its "brain". The brain provides receptors - the event handlers - to react on events coming from the outside. For example, when the player clicks an entity, its script(s) will receive a "LeftClick" event etc. You can also define your own events (so called high-level events), like the "LookAt" or "TalkTo" events used by the default project template.
As for the keypad example, there are several ways of accomplishing that, but probably the most suitable way would be to create a GUI window with a set of buttons. The window also has a script attached, and whenever the player presses one of the buttons, their parent window will receive an event with the same name as the button name. So what you need to do is to create a .window file with ten buttons named "0" to "9". Then attach a script to that window, which will handle the keypresses like that:
on "0"
{
AddKey("0");
}
on "1"
{
AddKey("1");
}
...
And the AddKey() function would keep track of what keys have been pressed so far:
var Pressed = "";
function AddKey(KeyName)
{
Pressed = Pressed + KeyName;
if(Pressed=="12345")
{
// player entered the right code, do something
}
}