Index: /trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp	(revision 79779)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp	(revision 79780)
@@ -146,4 +146,5 @@
     UISoftKeyboardKey *lockKey(int iKeyPosition) const;
     void updateLockKeyStates(bool fCapsLockState, bool fNumLockState, bool fScrollLockState);
+    void reset();
 
 private:
@@ -177,4 +178,5 @@
     void setLayoutToEdit(UISoftKeyboardLayout *pLayout);
     void setPhysicalLayoutList(const QVector<UISoftKeyboardPhysicalLayout> &physicalLayouts);
+    void reset();
 
 protected:
@@ -197,5 +199,4 @@
     void prepareConnections();
     QWidget *prepareKeyCaptionEditWidgets();
-    void reset();
     void resetKeyWidgets();
     QGridLayout *m_pEditorLayout;
@@ -356,6 +357,8 @@
     void setCutout(int iCorner, int iWidth, int iHeight);
 
+    KeyState state() const;
+    void setState(KeyState state);
+
     void setParentWidget(UISoftKeyboardWidget* pParent);
-    KeyState state() const;
     QVector<LONG> scanCodeWithPrefix() const;
 
@@ -373,4 +376,5 @@
 
     void updateLockState(bool fLocked);
+    void reset();
 
 private:
@@ -572,4 +576,5 @@
       * from the guest OS. Parameter fXXXState is true if the corresponding key is locked. */
     void updateLockKeyStates(bool fCapsLockState, bool fNumLockState, bool fScrollLockState);
+    void reset();
 
 protected:
@@ -600,5 +605,4 @@
     bool               loadPhysicalLayout(const QString &strLayoutFileName, bool isNumPad = false);
     bool               loadKeyboardLayout(const QString &strLayoutName);
-    void               reset();
     void               prepareObjects();
     UISoftKeyboardPhysicalLayout *findPhysicalLayout(const QUuid &uuid);
@@ -820,4 +824,15 @@
     updateLockKeyState(fNumLockState, m_lockKeys.value(iNumLockPosition, 0));
     updateLockKeyState(fScrollLockState, m_lockKeys.value(iScrollLockPosition, 0));
+}
+
+void UISoftKeyboardPhysicalLayout::reset()
+{
+    for (int i = 0; i < m_rows.size(); ++i)
+    {
+        for (int j = 0; j < m_rows[i].keys().size(); ++j)
+        {
+            m_rows[i].keys()[j].reset();
+        }
+    }
 }
 
@@ -1555,4 +1570,9 @@
 }
 
+void UISoftKeyboardKey::setState(KeyState state)
+{
+    m_enmState = state;
+}
+
 void UISoftKeyboardKey::setParentWidget(UISoftKeyboardWidget* pParent)
 {
@@ -1650,4 +1670,9 @@
         return;
     updateState(fLocked);
+}
+
+void UISoftKeyboardKey::reset()
+{
+    m_enmState = KeyState_NotPressed;
 }
 
@@ -2552,12 +2577,13 @@
     if (!pKey || pKey->type() != KeyType_Modifier)
         return;
-    if (pKey->state() != KeyState_NotPressed)
-        return;
+
+    pKey->setState(KeyState_NotPressed);
+
     QVector<QPair<LONG, LONG> > sequence;
     sequence << pKey->usagePageIdPair();
     if (fRelease)
+        emit sigPutUsageCodesRelease(sequence);
+    else
         emit sigPutUsageCodesPress(sequence);
-    else
-        emit sigPutUsageCodesRelease(sequence);
 }
 
@@ -2751,4 +2777,11 @@
 {
     m_pressedModifiers.clear();
+    m_pKeyUnderMouse = 0;
+    m_pKeyBeingEdited = 0;
+    m_pKeyPressed = 0;
+    m_enmMode = Mode_Keyboard;
+
+    for (int i = 0; i < m_physicalLayouts.size(); ++i)
+        m_physicalLayouts[i].reset();
 }
 
@@ -3465,4 +3498,5 @@
 {
     saveSettings();
+    keyboard().ReleaseKeys();
 }
 
@@ -3832,3 +3866,12 @@
 }
 
+void UISoftKeyboard::reset()
+{
+    if (m_pKeyboardWidget)
+        m_pKeyboardWidget->reset();
+    if (m_pLayoutEditor)
+        m_pLayoutEditor->reset();
+    keyboard().ReleaseKeys();
+}
+
 #include "UISoftKeyboard.moc"
Index: /trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.h	(revision 79779)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.h	(revision 79780)
@@ -101,4 +101,5 @@
     void updateLayoutSelectorList();
     void setDialogGeometry(const QRect &geometry);
+    void reset();
     CKeyboard& keyboard() const;
 
