That should work, except occasionally it will miss some messages as if they happen between you calling PeekMessage and glfwPollEvents the GLFW message loop will ‘swallow’ them.
SetWindowsHookEx would be a more guaranteed solution to ensure you get all messages, though it’s slightly more complex to use so you could try the PeekMessage approach first.
An alternative is to modify the GLFW message function and maintain a fork, which might be easier.