--- a/net/minecraft/client/KeyboardListener.java
+++ b/net/minecraft/client/KeyboardListener.java
@@ -255,7 +255,9 @@
          }
 
          INestedGuiEventHandler inestedguieventhandler = this.field_197972_a.field_71462_r;
-         if (p_197961_5_ == 1 && (!(this.field_197972_a.field_71462_r instanceof ControlsScreen) || ((ControlsScreen)inestedguieventhandler).field_152177_g <= Util.func_211177_b() - 20L)) {
+
+         if ((!(this.field_197972_a.field_71462_r instanceof ControlsScreen) || ((ControlsScreen)inestedguieventhandler).field_152177_g <= Util.func_211177_b() - 20L)) {
+            if (p_197961_5_ == 1) {
             if (this.field_197972_a.field_71474_y.field_152395_am.func_197976_a(p_197961_3_, p_197961_4_)) {
                this.field_197972_a.func_228018_at_().func_198077_g();
                this.field_197972_a.field_71474_y.field_74353_u = this.field_197972_a.func_228018_at_().func_198113_j();
@@ -274,6 +276,8 @@
                });
                return;
             }
+            } else if (p_197961_5_ == 0 /*GLFW_RELEASE*/ && this.field_197972_a.field_71462_r instanceof ControlsScreen)
+               ((ControlsScreen)this.field_197972_a.field_71462_r).field_146491_f = null; //Forge: Unset pure modifiers.
          }
 
          boolean flag = inestedguieventhandler == null || !(inestedguieventhandler.func_241217_q_() instanceof TextFieldWidget) || !((TextFieldWidget)inestedguieventhandler.func_241217_q_()).func_212955_f();
@@ -289,10 +293,14 @@
             Screen.func_231153_a_(() -> {
                if (p_197961_5_ != 1 && (p_197961_5_ != 2 || !this.field_197973_b)) {
                   if (p_197961_5_ == 0) {
-                     aboolean[0] = inestedguieventhandler.func_223281_a_(p_197961_3_, p_197961_4_, p_197961_6_);
+                     aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onGuiKeyReleasedPre(this.field_197972_a.field_71462_r, p_197961_3_, p_197961_4_, p_197961_6_);
+                     if (!aboolean[0]) aboolean[0] = inestedguieventhandler.func_223281_a_(p_197961_3_, p_197961_4_, p_197961_6_);
+                     if (!aboolean[0]) aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onGuiKeyReleasedPost(this.field_197972_a.field_71462_r, p_197961_3_, p_197961_4_, p_197961_6_);
                   }
                } else {
-                  aboolean[0] = inestedguieventhandler.func_231046_a_(p_197961_3_, p_197961_4_, p_197961_6_);
+                  aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onGuiKeyPressedPre(this.field_197972_a.field_71462_r, p_197961_3_, p_197961_4_, p_197961_6_);
+                  if (!aboolean[0]) aboolean[0] = inestedguieventhandler.func_231046_a_(p_197961_3_, p_197961_4_, p_197961_6_);
+                  if (!aboolean[0]) aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onGuiKeyPressedPost(this.field_197972_a.field_71462_r, p_197961_3_, p_197961_4_, p_197961_6_);
                }
 
             }, "keyPressed event handler", inestedguieventhandler.getClass().getCanonicalName());
@@ -345,7 +353,7 @@
                }
             }
          }
-
+         net.minecraftforge.client.ForgeHooksClient.fireKeyInput(p_197961_3_, p_197961_4_, p_197961_5_, p_197961_6_);
       }
    }
 
@@ -355,12 +363,16 @@
          if (iguieventlistener != null && this.field_197972_a.func_213250_au() == null) {
             if (Character.charCount(p_197963_3_) == 1) {
                Screen.func_231153_a_(() -> {
-                  iguieventlistener.func_231042_a_((char)p_197963_3_, p_197963_4_);
+                  if (net.minecraftforge.client.ForgeHooksClient.onGuiCharTypedPre(this.field_197972_a.field_71462_r, (char)p_197963_3_, p_197963_4_)) return;
+                  if (iguieventlistener.func_231042_a_((char)p_197963_3_, p_197963_4_)) return;
+                  net.minecraftforge.client.ForgeHooksClient.onGuiCharTypedPost(this.field_197972_a.field_71462_r, (char)p_197963_3_, p_197963_4_);
                }, "charTyped event handler", iguieventlistener.getClass().getCanonicalName());
             } else {
                for(char c0 : Character.toChars(p_197963_3_)) {
                   Screen.func_231153_a_(() -> {
-                     iguieventlistener.func_231042_a_(c0, p_197963_4_);
+                     if (net.minecraftforge.client.ForgeHooksClient.onGuiCharTypedPre(this.field_197972_a.field_71462_r, c0, p_197963_4_)) return;
+                     if (iguieventlistener.func_231042_a_(c0, p_197963_4_)) return;
+                     net.minecraftforge.client.ForgeHooksClient.onGuiCharTypedPost(this.field_197972_a.field_71462_r, c0, p_197963_4_);
                   }, "charTyped event handler", iguieventlistener.getClass().getCanonicalName());
                }
             }
