Taken from here.
You need something like this:
glfwSetWindowUserPointer(window, this);
glfwSetKeyCallback(window, [](GLFWwindow * window, int key, int scancode, int action, int mods){
Window * win = static_cast<Window *>(glfwGetWindowUserPointer(window));
win->addCommand(win->m_events.at(key));
});