^this.
Depending on the language you're working in, there are several libraries that give you a window and render context as well as window input events, which seems to be what you're looking for.
Have a look at SDL, SFML, GLFW, those are C/C++ libs with bindings available for multiple other languages (C#, Python, etc etc).