From b0e7523bb44e9aa8374d3cfb97ef39f96dd889ea Mon Sep 17 00:00:00 2001 From: "Joskic, Ivan" Date: Wed, 6 May 2026 20:35:05 +0200 Subject: [PATCH 1/3] Use WasKeyJustPressed for ExitOnEscape --- .../src/11-Input-Management/MonoGameLibrary/Core.cs | 2 +- .../src/12-Collision-Detection/MonoGameLibrary/Core.cs | 2 +- .../learn-monogame-2d/src/13-Tilemap/MonoGameLibrary/Core.cs | 2 +- .../src/14-SoundEffects-And-Music/MonoGameLibrary/Core.cs | 2 +- .../src/15-Audio-Controller/MonoGameLibrary/Core.cs | 2 +- .../src/16-Working-With-SpriteFonts/MonoGameLibrary/Core.cs | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Tutorials/learn-monogame-2d/src/11-Input-Management/MonoGameLibrary/Core.cs b/Tutorials/learn-monogame-2d/src/11-Input-Management/MonoGameLibrary/Core.cs index bf6d551c..2d52b1e4 100644 --- a/Tutorials/learn-monogame-2d/src/11-Input-Management/MonoGameLibrary/Core.cs +++ b/Tutorials/learn-monogame-2d/src/11-Input-Management/MonoGameLibrary/Core.cs @@ -112,7 +112,7 @@ protected override void Update(GameTime gameTime) // Update the input manager Input.Update(gameTime); - if (ExitOnEscape && Input.Keyboard.IsKeyDown(Keys.Escape)) + if (ExitOnEscape && Input.Keyboard.WasKeyJustPressed(Keys.Escape)) { Exit(); } diff --git a/Tutorials/learn-monogame-2d/src/12-Collision-Detection/MonoGameLibrary/Core.cs b/Tutorials/learn-monogame-2d/src/12-Collision-Detection/MonoGameLibrary/Core.cs index d33570a4..0ae73903 100644 --- a/Tutorials/learn-monogame-2d/src/12-Collision-Detection/MonoGameLibrary/Core.cs +++ b/Tutorials/learn-monogame-2d/src/12-Collision-Detection/MonoGameLibrary/Core.cs @@ -112,7 +112,7 @@ protected override void Update(GameTime gameTime) // Update the input manager Input.Update(gameTime); - if (ExitOnEscape && Input.Keyboard.IsKeyDown(Keys.Escape)) + if (ExitOnEscape && Input.Keyboard.WasKeyJustPressed(Keys.Escape)) { Exit(); } diff --git a/Tutorials/learn-monogame-2d/src/13-Tilemap/MonoGameLibrary/Core.cs b/Tutorials/learn-monogame-2d/src/13-Tilemap/MonoGameLibrary/Core.cs index d33570a4..0ae73903 100644 --- a/Tutorials/learn-monogame-2d/src/13-Tilemap/MonoGameLibrary/Core.cs +++ b/Tutorials/learn-monogame-2d/src/13-Tilemap/MonoGameLibrary/Core.cs @@ -112,7 +112,7 @@ protected override void Update(GameTime gameTime) // Update the input manager Input.Update(gameTime); - if (ExitOnEscape && Input.Keyboard.IsKeyDown(Keys.Escape)) + if (ExitOnEscape && Input.Keyboard.WasKeyJustPressed(Keys.Escape)) { Exit(); } diff --git a/Tutorials/learn-monogame-2d/src/14-SoundEffects-And-Music/MonoGameLibrary/Core.cs b/Tutorials/learn-monogame-2d/src/14-SoundEffects-And-Music/MonoGameLibrary/Core.cs index d33570a4..0ae73903 100644 --- a/Tutorials/learn-monogame-2d/src/14-SoundEffects-And-Music/MonoGameLibrary/Core.cs +++ b/Tutorials/learn-monogame-2d/src/14-SoundEffects-And-Music/MonoGameLibrary/Core.cs @@ -112,7 +112,7 @@ protected override void Update(GameTime gameTime) // Update the input manager Input.Update(gameTime); - if (ExitOnEscape && Input.Keyboard.IsKeyDown(Keys.Escape)) + if (ExitOnEscape && Input.Keyboard.WasKeyJustPressed(Keys.Escape)) { Exit(); } diff --git a/Tutorials/learn-monogame-2d/src/15-Audio-Controller/MonoGameLibrary/Core.cs b/Tutorials/learn-monogame-2d/src/15-Audio-Controller/MonoGameLibrary/Core.cs index 5be33b6e..c44ea357 100644 --- a/Tutorials/learn-monogame-2d/src/15-Audio-Controller/MonoGameLibrary/Core.cs +++ b/Tutorials/learn-monogame-2d/src/15-Audio-Controller/MonoGameLibrary/Core.cs @@ -132,7 +132,7 @@ protected override void Update(GameTime gameTime) // Update the audio controller. Audio.Update(); - if (ExitOnEscape && Input.Keyboard.IsKeyDown(Keys.Escape)) + if (ExitOnEscape && Input.Keyboard.WasKeyJustPressed(Keys.Escape)) { Exit(); } diff --git a/Tutorials/learn-monogame-2d/src/16-Working-With-SpriteFonts/MonoGameLibrary/Core.cs b/Tutorials/learn-monogame-2d/src/16-Working-With-SpriteFonts/MonoGameLibrary/Core.cs index 5be33b6e..c44ea357 100644 --- a/Tutorials/learn-monogame-2d/src/16-Working-With-SpriteFonts/MonoGameLibrary/Core.cs +++ b/Tutorials/learn-monogame-2d/src/16-Working-With-SpriteFonts/MonoGameLibrary/Core.cs @@ -132,7 +132,7 @@ protected override void Update(GameTime gameTime) // Update the audio controller. Audio.Update(); - if (ExitOnEscape && Input.Keyboard.IsKeyDown(Keys.Escape)) + if (ExitOnEscape && Input.Keyboard.WasKeyJustPressed(Keys.Escape)) { Exit(); } From a26bd29ca53817ed1324d8b64c0884cebec1f49e Mon Sep 17 00:00:00 2001 From: "Joskic, Ivan" Date: Wed, 6 May 2026 20:36:07 +0200 Subject: [PATCH 2/3] Fix typo --- .../src/17-Scenes/DungeonSlime/Scenes/GameScene.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tutorials/learn-monogame-2d/src/17-Scenes/DungeonSlime/Scenes/GameScene.cs b/Tutorials/learn-monogame-2d/src/17-Scenes/DungeonSlime/Scenes/GameScene.cs index 3f7851bd..7f9ef577 100644 --- a/Tutorials/learn-monogame-2d/src/17-Scenes/DungeonSlime/Scenes/GameScene.cs +++ b/Tutorials/learn-monogame-2d/src/17-Scenes/DungeonSlime/Scenes/GameScene.cs @@ -249,7 +249,7 @@ private void AssignRandomBatVelocity() private void CheckKeyboardInput() { - // Get a reference to the keyboard inof + // Get a reference to the keyboard info KeyboardInfo keyboard = Core.Input.Keyboard; // If the escape key is pressed, return to the title screen From b181249565456372645f439fb42fe83fa3cfdb86 Mon Sep 17 00:00:00 2001 From: "Joskic, Ivan" Date: Wed, 6 May 2026 20:45:10 +0200 Subject: [PATCH 3/3] Use keyboard like other keys --- .../src/17-Scenes/DungeonSlime/Scenes/GameScene.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tutorials/learn-monogame-2d/src/17-Scenes/DungeonSlime/Scenes/GameScene.cs b/Tutorials/learn-monogame-2d/src/17-Scenes/DungeonSlime/Scenes/GameScene.cs index 7f9ef577..05f5c9a0 100644 --- a/Tutorials/learn-monogame-2d/src/17-Scenes/DungeonSlime/Scenes/GameScene.cs +++ b/Tutorials/learn-monogame-2d/src/17-Scenes/DungeonSlime/Scenes/GameScene.cs @@ -253,7 +253,7 @@ private void CheckKeyboardInput() KeyboardInfo keyboard = Core.Input.Keyboard; // If the escape key is pressed, return to the title screen - if (Core.Input.Keyboard.WasKeyJustPressed(Keys.Escape)) + if (keyboard.WasKeyJustPressed(Keys.Escape)) { Core.ChangeScene(new TitleScene()); }