October 2018
Beginner to intermediate
676 pages
18h 30m
English
In this recipe, we will learn how to capture keyboard press and release events, and use them to toggle the display of the legend to visible/invisible, and also display the amount of time the key is pressed (time difference between the key press event and the key release event).
When the X key is pressed, held for some time, and then released, it reverses the status of the legend from visible to invisible, or the reverse, and also displays the time (in seconds) in the output figure, for how long the key was held before releasing.
If any other key is pressed, held, and released, then it will not change anything in the figure, but the program prints the name of the key pressed and the hold time to sysout .
Read now
Unlock full access