As I found in the TCL-documentation Control-a is a shortcut for moving the cursor to the beginning of the line (which works at Linux). But when I use this shortcut at Windows11 it selects all the text in the text widget. There are many other differences regarding other shortcuts compared between Linux and Windows. I now have the problem that my tkinter application needs different shortcuts at Linux and at Windows.
I expected the shortcuts to be the same.
The shortcuts are not the same, in an attempt to have the widgets perform in a manner consistent with the operating system. For example, most windows users do not want control-a to move to the front of the line. They are used to control-a being select-all in every other windows app they use.
Tkinter doesn't provide a single function to switch between the different sets of bindings, but you can override the default bindings with whatever you want using the bind
method.
Many of these very basic keybindings are implemented as virtual events. So, instead of adding a custom binding you can also reassign the binding to whatever virtual event you want. The advantage to this approach is that you don't need to know what code to call to get identical behavior.
For example, to switch control-a from select-all to moving the cursor to the start of the line you might do something like this:
root.event_delete("<<SelectAll>>", "<Control-Key-a>")
root.event_add("<<LineStart>>", "<Control-Key-a>")
You can find the list of virtual events on the event man page. You can see where these events are defined by looking at the tk source code, in the file tk.tcl