# Which code module should map physical keys to abstract keys?

How do you bridge the gap between the library's low-level event system and your engine's high-level event system? (I'm not necessarily talking about key events, but also about quit events.)

At the top level of my event system, I send out KeyPressedEvents, KeyRelesedEvents and others of this kind. These high-level events only contain the abstract values of the keys (they don't say that Space way pressed, but that the JumpKey was pressed, for example).

Whose responsibility should it be to map the "JumpKey" to an actual key on the keyboard?

• What do you mean by 'who'? – Kylotan Dec 4 '11 at 22:34
• I believe Paul Manta is asking, in an OOP context, how to translate physical key/button presses to ingame events (e.g. how to make space = jump). Specifically: which object(s) should have that responsibility, and roughly how would they work? This exact issue has already been answered in Keyboard input system handling. – doppelgreener Dec 5 '11 at 0:04
• I'm tempted to edit the title to "Which code module should map physical keys to abstract keys?" but I'll let paul do that to be sure we're understanding him correctly. – jhocking Mar 21 '12 at 12:41

It basically works as follows: Input from all devices is gathered in a structure that can be queried from all systems that want to subscribe to input. A system can then define "Actions" (single keystrokes or chords) for which the abstract device structure is queried. If the specified action has been performed on the device, the ()-operator of the action returns true, indicating that the "input condition" the system has been waiting for is fulfilled.