Keys/keycodes as nice string array

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Post Reply
MolokoTheMole
Posts: 109
Joined: Tue Jan 09, 2007 1:18 pm

Keys/keycodes as nice string array

Post by MolokoTheMole »

Here's something that comes useful to me when doing controls configuration to let the user see what key he pressed.

Example usage:

Code: Select all


..,OnEvent( const irr::SEvent &event )
{
  if ( event.EventType == irr::EET_KEY_INPUT_EVENT )
 {
   printf( "Key pressed = %s", KeyNames[ event.KeyInput.Key ] );
 }
}
Outputs on pressed key:

Code: Select all

Key pressed = Return

Suggestions and fixes are welcome:

Code: Select all

static char *KeyNames[ ] = 
{
		"-",
		"Left Button",
		"Right Button",
		"Cancel",
		"Middle Button",
		"X Button 1",
		"X Button 2",
		"-",
		"Back",
		"Tab",
		"-",
		"-",
		"Clear",
		"Return",
		"-",
		"-",
		"Shift",
		"Control",
		"Menu",
		"Pause",
		"Capital",
		"Kana",
		"-",		
		"Junja",
		"Final",
		"Kanji",
		"-",
		"Escape",
		"Convert",
		"Nonconvert",
		"Accept",
		"Mode Change",
		"Space",
		"Priot",
		"Next",
		"End",
		"Home",
		"Left",
		"Up",
		"Right",
		"Down",
		"Select",
		"Print",
		"Execute",
		"Snapshot",
		"Insert",
		"Delete",
		"Help",
		"0",
		"1",
		"2",
		"3",
		"4",
		"5",
		"6",
		"7",
		"8",
		"9",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"A",
		"B",
		"C",
		"D",
		"E",
		"F",
		"G",
		"H",
		"I",
		"J",
		"K",
		"L",
		"M",
		"N",
		"O",
		"P",
		"Q",
		"R",
		"S",
		"T",
		"U",
		"V",
		"W",
		"X",
		"Y",
		"Z",
		"Left Windows",
		"Right Windows",
		"Apps",
		"-",
		"Sleep",
		"Numpad 0",
		"Numpad 1",
		"Numpad 2",
		"Numpad 3",
		"Numpad 4",
		"Numpad 5",
		"Numpad 6",
		"Numpad 7",
		"Numpad 8",
		"Numpad 9",
		"Numpad *",
		"Numpad +",
		"Numpad /",
		"Numpad -",
		"Numpad .",
		"Numpad /",
		"F1",
		"F2",
		"F3",
		"F4",
		"F5",
		"F6",
		"F7",
		"F8",
		"F9",
		"F10",
		"F11",
		"F12",
		"F13",
		"F14",
		"F15",
		"F16",
		"F17",
		"F18",
		"F19",
		"F20",
		"F21",
		"F22",
		"F23",
		"F24",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"Num Lock",
		"Scroll Lock",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"Left Shift",
		"Right Shight",
		"Left Control",
		"Right Control",
		"Left Menu",
		"Right Menu",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"Plus",
		"Comma",
		"Minus",
		"Period",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"-",
		"Attn",
		"CrSel",
		"ExSel",
		"Erase OEF",
		"Play",
		"Zoom",
		"PA1",
		"OEM Clear",
		"-"
};
Crimson Glory full Irrlicht game source code!
What I Do - my blog & dev log
Currently developing Link-Dead
sash
Competition winner
Posts: 35
Joined: Thu Nov 05, 2009 8:46 am
Location: Novosibirsk

Re: Keys/keycodes as nice string array

Post by sash »

Sorry, if I revived old thread, but just thanks: it comes handy and useful to me.
Post Reply