http://ai.neocities.org/AiSteps.html#SensoryInput
Start a subroutine or module that is able to sense something coming in from the outside world, i.e., a key-press on the keyboard.
First code recognition of the Escape-key (ASCII 27) for ending the AI.
Next code recognition of the Tab-key (ASCII 9) for mode-selection.
Then code recognition of the Enter-key (ASCII 13) for ending input.
Take the ESCAPE-key handler or other mechanism of stopping the AI out of the MainLoop and transfer it to the SensoryInput stub. Keep in mind that you must keep a quit-mechanism in the Mind. Flesh out the SensoryInput stub into a working mind-module that calls its own stubs, such as AudInput, VisRecog, TacRecog, GusRecog and OlfRecog. Test the embryonic robot mind by demonstrating that the MainLoop either waits briefly for SensoryInput during each cycle, or generates an event-driven response to input detected by a SensoryInput module. The proper response will be to keep cycling upon normal input or to terminate execution upon halt [ESCAPE] input. Share your code on the Web.
Now you have two modules, a MainLoop module and a subordinate, SensoryInput module. But what should come next in AI evolution? Now we need a reaction module, so that the organism may react to its environment. Let's call the reaction-module "ThInk".
http://code.google.com/p/mindforth/wiki/SensoryInput