Question

Is there any way to detect which keys are currently pressed using Tkinter? I don't want to have to use extra libraries if possible. I can already detect when keys are pressed, but I want to be able to check at any time what keys are pressed down at the moment.

Was it helpful?

Solution

I think you need to keep track of events about keys getting pressed and released (maintaining your own set of "currently pressed" keys) -- I believe Tk doesn't keep track of that for you (and Tkinter really adds little on top of Tk, it's mostly a direct interface to it).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top