         Serial.println(after, HEX);
 #endif
 
+        MODIFIERKEYS beforeModifiers = *((MODIFIERKEYS*)&before);
+        MODIFIERKEYS afterModifiers = *((MODIFIERKEYS*)&after);
+
+        if (!beforeModifiers.bmLeftCtrl && afterModifiers.bmLeftCtrl) {
+            keyDown(KEY_LEFT_CTRL);
+        } else if (beforeModifiers.bmLeftCtrl && !afterModifiers.bmLeftCtrl) {
+            keyUp(KEY_LEFT_CTRL);
+        }
+
+        if (!beforeModifiers.bmLeftShift && afterModifiers.bmLeftShift) {
+            keyDown(KEY_LEFT_SHIFT);
+        } else if (beforeModifiers.bmLeftShift && !afterModifiers.bmLeftShift) {
+            keyUp(KEY_LEFT_SHIFT);
+        }
+
+        if (!beforeModifiers.bmLeftAlt && afterModifiers.bmLeftAlt) {
+            keyDown(KEY_LEFT_ALT);
+        } else if (beforeModifiers.bmLeftAlt && !afterModifiers.bmLeftAlt) {
+            keyUp(KEY_LEFT_ALT);
+        }
+
+        if (!beforeModifiers.bmLeftGUI && afterModifiers.bmLeftGUI) {
+            keyDown(KEY_LEFT_GUI);
+        } else if (beforeModifiers.bmLeftGUI && !afterModifiers.bmLeftGUI) {
+            keyUp(KEY_LEFT_GUI);
+        }
+
+        if (!beforeModifiers.bmRightCtrl && afterModifiers.bmRightCtrl) {
+            keyDown(KEY_RIGHT_CTRL);
+        } else if (beforeModifiers.bmRightCtrl && !afterModifiers.bmRightCtrl) {
+            keyUp(KEY_RIGHT_CTRL);
+        }
+
+        if (!beforeModifiers.bmRightShift && afterModifiers.bmRightShift) {
+            keyDown(KEY_RIGHT_SHIFT);
+        } else if (beforeModifiers.bmRightShift && !afterModifiers.bmRightShift) {
+            keyUp(KEY_RIGHT_SHIFT);
+        }
+
+        if (!beforeModifiers.bmRightAlt && afterModifiers.bmRightAlt) {
+            keyDown(KEY_RIGHT_ALT);
+        } else if (beforeModifiers.bmRightAlt && !afterModifiers.bmRightAlt) {
+            keyUp(KEY_RIGHT_ALT);
+        }
+
+        if (!beforeModifiers.bmRightGUI && afterModifiers.bmRightGUI) {
+            keyDown(KEY_RIGHT_GUI);
+        } else if (beforeModifiers.bmRightGUI && !afterModifiers.bmRightGUI) {
+            keyUp(KEY_RIGHT_GUI);
+        }
+    }
+
+private:
+    void keyDown(KeyboardKeycode key) {
+#if OUTPUT_TO_SERIAL
+        Serial.print("mode:  ");
+        Serial.print(keyboardState.currentMode, HEX);
+        Serial.print(" key down:  ");
+        Serial.println(key, HEX);
+#endif
+
         switch (keyboardState.currentMode) {
             case MODE_NEUTRAL:
-                changeModifiers(after);
+                Keyboard.press(key);
                 return;
 
             case MODE_DUDRACK:
-                dudrackModifiersChange(after);
+                dudrackKeyDown(key);
                 return;
 
             case MODE_STG:
-                stgModifiersChange(after);
+                stgKeyDown(key);
+                return;
+        }
+    }
+
+    void keyUp(KeyboardKeycode key) {
+#if OUTPUT_TO_SERIAL
+        Serial.print("mode:  ");
+        Serial.print(keyboardState.currentMode, HEX);
+        Serial.print(" key up:  ");
+        Serial.println(key, HEX);
+#endif
+
+        switch (keyboardState.currentMode) {
+            case MODE_NEUTRAL:
+                Keyboard.release(key);
+                return;
+
+            case MODE_DUDRACK:
+                dudrackKeyUp(key);
+                return;
+
+            case MODE_STG:
+                stgKeyUp(key);
                 return;
         }
     }

    return false;
}

void dudrackKeyDown(uint8_t key) {
    switch (key) {
        case KEY_HENKAN:
            keyboardState.henkanPressed = true;

            return;

        case KEY_MUHENKAN:
            pressModifier(MODIFIER_LEFT_SHIFT);
            keyboardState.muhenkanPressed = true;

            return;

        case KEY_SPACE:
            pressModifier(MODIFIER_LEFT_SHIFT);
            keyboardState.spacePressed = true;
            keyboardState.noEventBetweenSpaceEvents = true;


            keyboardState.noEventBetweenSpaceEvents = false;

            if (keyboardState.henkanPressed || keyboardState.muhenkanPressed) {
                Keyboard.press(keyMappings[MAPPING_HENKAN][key]);
            } else {
                Keyboard.press(keyMappings[MAPPING_NEUTRAL][key]);
            }
    }
}

void dudrackKeyUp(KeyboardKeycode key) {
    switch (key) {
        case KEY_LEFT_SHIFT:
            keyboardState.leftShiftPressed = false;
            releaseLeftShift();

            return;

        case KEY_HENKAN:
            keyboardState.henkanPressed = false;

