Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The Ctrl+Shift+a not working inTkinter bind_all

I am trying to recreate the notepad. I have added a lot of shortcut keys with a combination of two keys. I am trying to make a three combination shortcut, which will be Ctrl+Shift+s. But when I used <Control-Shift-Key-s> it's not working. I had even tried app.bind<Control-Shift-KeyPress-s> which I found at the Control+Shift+Tab key binding in stack overflow. When I used Tab instead of s that worked, when I use s nothing happens. I want to create a key binding of Control+Shift+s. How Can I Do That?
This Is My Code:

from tkinter import *

app = Tk()

def SaveAs(event):
    #Some code to save as new file.
    print('Pressed Ctrl+Shift+s.')

app.bind_all('<Control-Shift-Key-s>', SaveAs)
like image 384
Parvat . R Avatar asked Feb 21 '26 13:02

Parvat . R


1 Answers

Make sure that you are not mixing up uppercase and lowercase, because in Tkinter, "<Control-S>" means CTRL-SHIFT-S and "<Control-s>" means CTRL-S.

So, this line:

app.bind_all('<Control-Shift-Key-s>', SaveAs)

must be

app.bind_all('<Control-S>', SaveAs)