1ea1d6981Smrg 2ea1d6981Smrg<chapter id='Key_Event_Processing_Overview'> 3ea1d6981Smrg<title>Key Event Processing Overview</title> 4ea1d6981Smrg 5ea1d6981Smrg<para> 6ea1d6981SmrgThere are three steps to processing each key event in the X server, and at 7ea1d6981Smrgleast three in the client. This section describes each of these steps briefly; 8ea1d6981Smrgthe following sections describe each step in more detail. 9ea1d6981Smrg</para> 10ea1d6981Smrg 11ea1d6981Smrg<orderedlist> 12ea1d6981Smrg<listitem> 13ea1d6981Smrg <para>First, the server applies global keyboard controls to determine whether 14ea1d6981Smrgthe key event should be processed immediately, deferred, or ignored. For 15ea1d6981Smrgexample, the <emphasis> 16ea1d6981SmrgSlowKeys</emphasis> 17ea1d6981Smrg control can cause a key event to be deferred until the slow keys delay has 18ea1d6981Smrgelapsed while the <emphasis> 19ea1d6981SmrgRepeatKeys</emphasis> 20ea1d6981Smrg control can cause multiple X events from a single physical key press if the 21ea1d6981Smrgkey is held down for an extended period. The global keyboard controls affect 22ea1d6981Smrgall of the keys on the keyboard and are described in 23ea1d6981Smrg<link linkend='Global_Keyboard_Controls'>Global Keyboard Controls</link>. 24ea1d6981Smrg </para> 25ea1d6981Smrg</listitem> 26ea1d6981Smrg<listitem> 27ea1d6981Smrg <para>Next, the server applies per-key behavior. Per key-behavior can be used 28ea1d6981Smrgto simulate or indicate some special kinds of key behavior. For example, 29ea1d6981Smrgkeyboard overlays, in which a key generates an alternate keycode under certain 30ea1d6981Smrgcircumstances, can be implemented using per-key behavior. Every key has a 31ea1d6981Smrgsingle behavior, so the effect of key behavior does not depend on keyboard 32ea1d6981Smrgmodifier or group state, though it might depend on global keyboard controls. 33ea1d6981SmrgPer-key behaviors are described in detail in 34ea1d6981Smrg<link linkend='Key_Behavior'>Key Behavior</link>. 35ea1d6981Smrg </para> 36ea1d6981Smrg</listitem> 37ea1d6981Smrg<listitem> 38ea1d6981Smrg <para>Finally, the server applies key actions. Logically, every keysym on the 39ea1d6981Smrgkeyboard has some action associated with it. The key action tells the server 40ea1d6981Smrgwhat to do when an event which yields the corresponding keysym is generated. 41ea1d6981SmrgKey actions might change or suppress the event, generate some other event, or 42ea1d6981Smrgchange some aspect of the server. Key actions are described in <link linkend='Key_Actions'>Key Actions</link>. 43ea1d6981Smrg </para> 44ea1d6981Smrg</listitem> 45ea1d6981Smrg</orderedlist> 46ea1d6981Smrg 47ea1d6981Smrg<para> 48ea1d6981SmrgIf the global controls, per-key behavior and key action combine to cause a key 49ea1d6981Smrgevent, the client which receives the event processes it in several steps. 50ea1d6981Smrg</para> 51ea1d6981Smrg 52ea1d6981Smrg<orderedlist> 53ea1d6981Smrg<listitem> 54ea1d6981Smrg <para>First the client extracts the effective keyboard group and a set of 55ea1d6981Smrgmodifiers from the state field of the event. See <link linkend='Computing_A_State_Field_from_an_XKB_State'>Computing A State Field from an XKB 56ea1d6981SmrgState</link> for details. 57ea1d6981Smrg </para> 58ea1d6981Smrg</listitem> 59ea1d6981Smrg<listitem> 60ea1d6981Smrg <para>Using the modifiers and effective keyboard group, the client selects a 61ea1d6981Smrgsymbol from the list of keysyms bound to the key. <link linkend='Determining_the_KeySym_Associated_with_a_Key_Event'>Determining the KeySym Associated with a 62ea1d6981SmrgKey Event</link> discusses symbol selection. 63ea1d6981Smrg </para> 64ea1d6981Smrg</listitem> 65ea1d6981Smrg<listitem> 66ea1d6981Smrg <para>If necessary, the client transforms the symbol and resulting string 67ea1d6981Smrgusing any modifiers that are "left over" from the process of looking up a 68ea1d6981Smrgsymbol. For example, if the <emphasis> 69ea1d6981SmrgLock</emphasis> 70ea1d6981Smrg modifier is left over, the resulting keysym is capitalized according to the 71ea1d6981Smrgcapitalization rules specified by the system. See 72ea1d6981Smrg<link linkend='Transforming_the_KeySym_Associated_with_a_Key_Event'> 73ea1d6981SmrgTransforming the KeySym Associated with a 74ea1d6981SmrgKey Event</link> for a more detailed discussion of the transformations defined 75ea1d6981Smrgby XKB. 76ea1d6981Smrg </para> 77ea1d6981Smrg</listitem> 78ea1d6981Smrg<listitem> 79ea1d6981Smrg <para>Finally, the client uses the keysym and remaining modifiers in an 80ea1d6981Smrgapplication-specific way. For example, applications based on the X toolkit 81ea1d6981Smrgmight apply translations based on the symbol and modifiers reported by the 82ea1d6981Smrgfirst three steps. 83ea1d6981Smrg </para> 84ea1d6981Smrg</listitem> 85ea1d6981Smrg</orderedlist> 86ea1d6981Smrg</chapter> 87