# Keyboard callbacks blocks mouse button callback

**URL:** <https://discourse.glfw.org/t/keyboard-callbacks-blocks-mouse-button-callback/1503>\
**Category:** support\
**Created:** [March 1, 2020, 2:31pm UTC](https://discourse.glfw.org/t/keyboard-callbacks-blocks-mouse-button-callback/1503 "2020-03-01T14:31:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![IRCSS](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/ircss/32/314_2.png) [@IRCSS](https://discourse.glfw.org/u/IRCSS)\
**Post date:** [March 1, 2020, 2:31pm UTC](https://discourse.glfw.org/t/keyboard-callbacks-blocks-mouse-button-callback/1503/1 "2020-03-01T14:31:19Z")

</div>

Hey guys, I can’t find anything on this on Google, I am not quite sure what I am doing wrong.

So I have two methods setup to register key presses using the glfwSetMouseButtonCallback and glfwSetKeyCallback. The methods are in this file, [https://github.com/IRCSS/ToyRenderer/blob/master/src/InputMaster.cpp](https://github.com/IRCSS/ToyRenderer/blob/master/src/InputMaster.cpp)

The call backs work fine on their own, used in combination, they also work fine one way but not the other way around. If I press for example the right mouse key, hold and press for example keyboard S key, I get callbacks from both mouse and keyboard, but if I hold S key first and then click the mouse button right, I wont get callback for mouse button, only for the keyboard key. Then after I let go of the S key, I need to press the mouse button at least twice to get a callback. Keyboad with Keyboard works without a problem.

I am on windows 10, visual studio 2018 and GLFW 3.3. The binding of my function with the callback happens in the constructor of the InputMaster. InputMaster is created in Application.cpp [https://github.com/IRCSS/ToyRenderer/blob/master/src/Application.cpp](https://github.com/IRCSS/ToyRenderer/blob/master/src/Application.cpp)

Any ideas what I am doing wrong? Btw I am printing out these information first thing as the callback is called, so I doubt the issue is on the abstraction I am adding on top.

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [March 1, 2020, 3:53pm UTC](https://discourse.glfw.org/t/keyboard-callbacks-blocks-mouse-button-callback/1503/2 "2020-03-01T15:53:51Z")

</div>

Your code is a little complicated to follow with a quick look. I suggest some practical debugging:

1. Add printf’s to the `OnKeyPressed` and `OnMouseButtonPressed` making sure you output all information and do so before any of your code.
2. Use break points to check code flow when a key/mouse button is pressed.

---

<div class="post-metadata">

**Author:** ![IRCSS](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/ircss/32/314_2.png) [@IRCSS](https://discourse.glfw.org/u/IRCSS)\
**Post date:** [March 2, 2020, 9:40pm UTC](https://discourse.glfw.org/t/keyboard-callbacks-blocks-mouse-button-callback/1503/3 "2020-03-02T21:40:09Z")

</div>

Thanks for the reply.  
I print first thing in OnKeyPressed and OnMouseButtonPressed before any of my code. The mouse button callback is not called at all if a keyboard key is pressed. Same thing with break points, it never gets to a line I can set, since the callback itself is not called.  
Interesting thing is, I tested the code on a different machine at work, and the callback is called without any problems there. Both windows/ visual studio 2018.

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [March 3, 2020, 8:28am UTC](https://discourse.glfw.org/t/keyboard-callbacks-blocks-mouse-button-callback/1503/4 "2020-03-03T08:28:22Z")

</div>

There is a test called [events.c](https://github.com/glfw/glfw/blob/master/tests/events.c) in the glfw tests code folder. If you can run this you can use it to verify whether GLFW is getting the inputs correctly.
