OT What does RET (Enter) do and how does it do it ??

Alan M. Evans fedoralist at alanevans.org
Fri Aug 24 22:12:30 UTC 2007


It sounds to me as though you are laboring under the false assumption
that pressing <Enter> invokes some special system call, and that, for
example, pressing <A> or <Spacebar> does not. Is this what you're
thinking?

Over-simplifying:

Pressing any key simply produces a keycode. The system first looks and
decides it has nothing to do with the <Enter> keycode, so it passes the
keycode on to the next entity that might be interested in a key press.

For simplicity, lets say that the next guy is the Window Manager. The
Window Manager examines the keycode and decides that it doesn't know how
to handle this key, so it passes the keycode on to the next entity that
might be interested in a key press.

We'll call the next entity the Focused Program. And here's where it gets
interesting. The Focused Program receives the keycode and handles it by
whatever context exists in the program. If the Focused Program is xterm
or gnome-terminal or such then it does as you've described.

If the Focused Program has a Focused Widget (a text entry or menu or
whatever) then it will likely pass the keycode on to the routines that
handle events for that Widget, so that the Widget becomes the context
for how the key is handled.

No magic. All keys are handled the same way. (With some special
consideration for combination keys like <shift> or <ctrl>.)

If all of this is obvious to you then I've clearly misunderstood what
you're having trouble understanding. If so, sorry, move along...
 




More information about the users mailing list