Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is a :

Key-Event Dispatcher ?

in keyboard-interactive apps.

What does it really do ?

share|improve this question

closed as unclear what you're asking by gnat, MichaelT, Ixrec, GlenH7, Bart van Ingen Schenau Jan 28 at 18:49

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

up vote -1 down vote accepted

Without more context it is hard to be sure, but usually that would be the small piece of code that receives the information "A key of the type X was just pressed/released/kept down for certain time" and then does whatever the program is supposed to to in response. (For instance, in emacs most letter keys trigger the aptly named self-insert-command, while modifier keys change the state of the program so that the next key event will do something different from the normal response.)

It can come as a surprise to beginners, but there is really no intrinsic reason why pressing an 'a' key would let a computer program react by printing an 'a' character. Programmable computers are Turing-complete machines, they can in principle give any conceivable response to any input - if you want the typewriter-like 'copying' behaviour (and in editors, shells etc. that is usually the case), the code has to be told explicitly to do it. The keyboard event dispatcher takes care of that.

share|improve this answer

it listens to all keyboard events and dispatches the events to those listeners that want it (characters to the text box, tab to the focus manager, shortcuts to the respective handler...)

this can be more efficient that everything listening to the keyboard and doing an if test, if the dispatcher uses (for example) a hash map to quickly find where to send the event

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.