Index: code/branches/presentation2/data/gui/scripts/KeyBindMenu.lua
===================================================================
--- code/branches/presentation2/data/gui/scripts/KeyBindMenu.lua	(revision 6280)
+++ code/branches/presentation2/data/gui/scripts/KeyBindMenu.lua	(revision 6281)
@@ -86,8 +86,9 @@
     
     openInfoPopup("Press any button/key or move a mouse/joystick axis.", KeyBindMenu.keybind)
-
 end
 
 function P.keybind()
+    local funct = luaState:createLuaFunctor("InfoPopup:close()")
+    orxonox.KeyBinderManager:getInstance():registerKeybindCallback(funct)
     orxonox.KeyBinderManager:getInstance():keybind(commandList[commandNr])
 end
Index: code/branches/presentation2/src/libraries/core/LuaState.cc
===================================================================
--- code/branches/presentation2/src/libraries/core/LuaState.cc	(revision 6280)
+++ code/branches/presentation2/src/libraries/core/LuaState.cc	(revision 6281)
@@ -263,3 +263,15 @@
         }
     }
+
+
+    LuaFunctor::LuaFunctor(const std::string& code, LuaState* luaState)
+    {
+        this->code_ = code;
+        this->lua_ = luaState;
+    }
+
+    void LuaFunctor::operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5)
+    {
+        lua_->doString(this->code_);
+    }
 }
Index: code/branches/presentation2/src/libraries/core/LuaState.h
===================================================================
--- code/branches/presentation2/src/libraries/core/LuaState.h	(revision 6280)
+++ code/branches/presentation2/src/libraries/core/LuaState.h	(revision 6281)
@@ -40,16 +40,31 @@
 
 #include "util/ScopeGuard.h"
+#include "core/Functor.h"
 #include "ToluaInterface.h"
 
-// tolua_begin
-namespace orxonox
-{
+namespace orxonox // tolua_export
+{ // tolua_export
+    class Functor; // tolua_export
+
+    //! Functor subclass that simply executes code with 0 arguments.
+    class _CoreExport LuaFunctor : public Functor
+    {
+        public:
+            LuaFunctor(const std::string& code, LuaState* luaState);
+            void operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null);
+            void evaluateParam(unsigned int index, MultiType& param) const {}
+
+        private:
+            std::string code_;
+            LuaState*   lua_;
+    };
+
+
     /**
     @brief
         Representation of an interface to lua
     */
-    class _CoreExport LuaState
-    {
-// tolua_end
+    class _CoreExport LuaState // tolua_export
+    { // tolua_export
     public:
         LuaState();
@@ -74,4 +89,6 @@
         void setDefaultResourceInfo(const shared_ptr<ResourceInfo>& sourceFileInfo) { this->sourceFileInfo_ = sourceFileInfo; }
         const shared_ptr<ResourceInfo>& getDefaultResourceInfo() { return this->sourceFileInfo_; }
+
+        Functor* createLuaFunctor(const std::string& code) { return new LuaFunctor(code, this); } // tolua_export
 
         static bool addToluaInterface(int (*function)(lua_State*), const std::string& name);
Index: code/branches/presentation2/src/libraries/core/input/KeyBinderManager.cc
===================================================================
--- code/branches/presentation2/src/libraries/core/input/KeyBinderManager.cc	(revision 6280)
+++ code/branches/presentation2/src/libraries/core/input/KeyBinderManager.cc	(revision 6281)
@@ -29,4 +29,6 @@
 #include "KeyBinderManager.h"
 
+#include <CEGUIWindow.h>
+
 #include "util/Debug.h"
 #include "util/Exception.h"
@@ -37,6 +39,4 @@
 #include "InputManager.h"
 #include "KeyDetector.h"
-
-#include <CEGUIWindow.h>
 
 namespace orxonox
@@ -49,6 +49,4 @@
         , bBinding_(false)
     {
-        this->callbackFunction_ = createFunctor(&KeyBinderManager::callback, this);
-
         RegisterObject(KeyBinderManager);
         this->setConfigValues();
@@ -69,5 +67,4 @@
         for (std::map<std::string, KeyBinder*>::const_iterator it = this->binders_.begin(); it != this->binders_.end(); ++it)
             delete it->second;
-        delete this->callbackFunction_;
     }
 
@@ -152,5 +149,5 @@
         {
             COUT(0) << "Press any button/key or move a mouse/joystick axis" << std::endl;
-            KeyDetector::getInstance().setCallback(callbackFunction_);
+            KeyDetector::getInstance().setCallback(shared_ptr<Functor>(createFunctor(&KeyBinderManager::keybindKeyPressed, this)));
             InputManager::getInstance().enterState("detector");
             this->command_ = command;
@@ -162,5 +159,5 @@
 
     // Gets called by the KeyDetector (registered with a Functor)
-    void KeyBinderManager::callback(const std::string& keyName)
+    void KeyBinderManager::keybindKeyPressed(const std::string& keyName)
     {
         if (this->bBinding_)
@@ -169,4 +166,7 @@
             this->currentBinder_->setBinding(command_, keyName, bTemporary_);
             InputManager::getInstance().leaveState("detector");
+            // inform whatever was calling the command
+            if (this->callbackFunction_)
+                (*this->callbackFunction_)();
             this->bBinding_ = false;
         }
Index: code/branches/presentation2/src/libraries/core/input/KeyBinderManager.h
===================================================================
--- code/branches/presentation2/src/libraries/core/input/KeyBinderManager.h	(revision 6280)
+++ code/branches/presentation2/src/libraries/core/input/KeyBinderManager.h	(revision 6281)
@@ -34,8 +34,9 @@
 #include <map>
 #include <string>
+#include <boost/shared_ptr.hpp>
+#include <CEGUIForwardRefs.h>
+
 #include "util/Singleton.h"
 #include "core/OrxonoxClass.h"
-
-#include <CEGUIForwardRefs.h>
 
 namespace orxonox //tolua_export
@@ -99,9 +100,10 @@
         inline void tkeybind(const std::string& command)
             { this->keybindInternal(command, true); }
+        inline void registerKeybindCallback(Functor* function) { this->callbackFunction_.reset(function); } // tolua_export
 
     private:
         KeyBinderManager(const KeyBinderManager&);
         void keybindInternal(const std::string& command, bool bTemporary);
-        void callback(const std::string& keyName);
+        void keybindKeyPressed(const std::string& keyName);
         void defaultFilenameChanged();
 
@@ -113,5 +115,5 @@
 
         // keybind command related
-        Functor* callbackFunction_;                  //! Function to be called when key was pressed after "keybind" command
+        shared_ptr<Functor> callbackFunction_;       //! Function to be called when key was pressed after "keybind" command
         bool bBinding_;                              //! Tells whether a key binding process is active
         bool bTemporary_;                            //! Stores tkeybind/keybind value
Index: code/branches/presentation2/src/libraries/core/input/KeyDetector.h
===================================================================
--- code/branches/presentation2/src/libraries/core/input/KeyDetector.h	(revision 6280)
+++ code/branches/presentation2/src/libraries/core/input/KeyDetector.h	(revision 6281)
@@ -32,4 +32,5 @@
 #include "InputPrereqs.h"
 
+#include <boost/shared_ptr.hpp>
 #include "util/Singleton.h"
 #include "KeyBinder.h"
@@ -45,5 +46,5 @@
         ~KeyDetector();
 
-        void setCallback(Functor* function) { this->callbackFunction_ = function; }
+        void setCallback(const shared_ptr<Functor>& function) { this->callbackFunction_ = function; }
 
     private:
@@ -54,5 +55,5 @@
         void assignCommands();
 
-        Functor* callbackFunction_;
+        shared_ptr<Functor> callbackFunction_;
         InputState* inputState_;
         static std::string callbackCommand_s;
