A short code to destroy the image window or to save the image in a file using keyboard buttons.
Here we are storing the entered key in the variable ‘key’
Then we check which key is pressed . The ASCII code for escape button is ’27’ , if ‘escape’ button is pressed then the window will be destroyed
If ‘s’ button is pressed then the image will be saved. For this we use the function ord() and pass the parameter as ‘s’. So on hitting the ‘s’ button on our keyboard the image will be saved automatically.