+ if( !down ) {
+ if( bind && bind[ 0 ] == '+') {
+ Cbuf_AddText( va( "-%s %i\n", bind + 1, key) );
+ }
+ } else {
+ // handle ESCAPE specially, so unbinding wont help
+ if( key == K_ESCAPE ) {
+ // shift-escape is a safety measure for users who cant toggle the console otherwise
+ if( keydown[K_SHIFT] ) {
+ Con_ToggleConsole_f();
+ return;
+ }
+ switch( key_dest ) {
+ case key_message:
+ Key_Message( key, ascii );
+ break;
+ case key_menu:
+ MR_Keydown( key, ascii );
+ break;
+ case key_game:
+ if (COM_CheckParm ("-demolooponly"))
+ {
+ CL_Disconnect ();
+ return;
+ }
+ MR_ToggleMenu_f();
+ break;
+ default:
+ Sys_Error( "Bad key_dest" );
+ }
+ return;
+ }
+
+ if( !(key_consoleactive && consolekeys[ key ]) && bind && !strncmp( bind, "toggleconsole", strlen( "toggleconsole" ) ) ) {
+ Cbuf_AddText( bind );
+ Cbuf_AddText( "\n" );
+ if( ascii != STRING_COLOR_TAG ) {
+ return;
+ }
+ } else {
+ // during demo playback, all keys ingame bring up the main menu
+ if( cls.demoplayback && !key_consoleactive && key_dest == key_game ) {
+ if (!COM_CheckParm ("-demolooponly"))
+ MR_ToggleMenu_f ();
+ return;
+ }
+
+ // menu bind/function keys or normal binds
+ if( (key_dest == key_menu && menubound[key]) || USERPLAYING() ) {
+ if( bind ) {
+ if( bind[0] == '+' ) { // button commands add keynum as a parm
+ Cbuf_AddText( va( "%s %i\n", bind, key ) );
+ } else {
+ Cbuf_AddText( bind );
+ Cbuf_AddText( "\n" );
+ }
+ }
+ return;
+ }
+ }
+
+ // either console or game state key functions
+ if( key_consoleactive ) {
+ Key_Console( key, ascii );
+ } else {
+ switch (key_dest) {
+ case key_message:
+ Key_Message( key, ascii );
+ break;
+ case key_menu:
+ MR_Keydown( key, ascii );
+ break;
+ case key_game:
+ // unbound key
+ break;
+ default:
+ Sys_Error( "Bad key_dest" );
+ }
+ }
+ }
+#elif 1
+#define USERPLAYING() ( !key_consoleactive && key_dest == key_game && (cls.state == ca_connected && cls.signon == SIGNONS) )
+ const char *bind;
+
+ // get key binding
+ bind = keybindings[key_bmap][key];
+ if (!bind)
+ bind = keybindings[key_bmap2][key];
+
+ if (!down)