Tk Source Code

View Ticket
Login
Ticket UUID: 433261290b533e74aa8c372e4b4dfd5ef28b478e
Title: Copy&Paste with (some) non Latin keyboard layout
Type: Bug Version: 8.6.9
Submitter: anonymous Created on: 2019-05-21 14:15:14
Subsystem: 01. Bindings Assigned To: oehhar
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2026-09-21 08:34:51
Resolution: Fixed Closed By: oehhar
    Closed on: 2026-09-21 08:34:51
Description:
On Windows 10, I have noticed that all Tk widgets are not capable of Copy and Paste with some keyboard layout, such as Ukranian and Russian. With other layouts, copy and paste works just out-of-the-box. On any other application I tried, copy and paste works even with Ukranian and Russian. Note that the keys for copy and paste are always the same physical keys on these keyboards. On macOS I could not reproduce the issue.
User Comments: oehhar added on 2026-09-21 08:34:51:

Thanks! Merged by

  • [6c568d49] to main
  • [8b04a295] to core-9-0-branch
  • [3074dc4b] to core-8-6-branch

Bug closed.

THanks for all, Harald


serhiy.storchaka added on 2026-09-17 16:23:49:

Thank you, Harald.

The fix is now also on a branch based on main: win-nonlatin-shortcuts-main, [c5279d17a0]. It contains the same code, test and bind(n) paragraph as the 8.6-based branch win-nonlatin-shortcuts ([3eafc907b3] and [c8a0182f25]); only the man page context differs (<Control-Key-comma> instead of <Control-KeyPress-comma>). The 8.6 branch can stay for whoever wants to backport it, or be closed.

The X11 side is a separate ticket, [701d8f8953], with the fix on branch x11-nonlatin-shortcuts ([b052917bd2]). The script-level behaviour is the same: <Control-q> and <Alt-q> match the Q/Й key with a Cyrillic layout, %A still gives й.


oehhar added on 2026-09-17 16:23:37:

I have tested it with a Greek keyboard and the Windows on-screen keyboard (as it shows what the key is if you have no Greek physical keyboard).

It works as expected. Ctrl+ψ triggers the binding:

bind . <control-c> "puts ."

If CI is clean, I will merge to all branches next Monday (AFK Fr-Sun) (if nobody else is faster).

Thanks for all, Harald


oehhar added on 2026-09-17 12:14:27:

Thanks, Serhi.

That all sounds reasonable. Thanks for all.

You may choose, if you handle the X11 fix here or with a separate ticket.

I would go for a separate for practical reasons, as the platforms are internally different. It would be great, if it behaves the same on the script level.

This branch is based on 8.6. My local 8.6 test chain does not exist any more, but this may change. I don't know, if the CI may still be started for 8.6. For me, it would be better to have patches from the main branch. But maybe, someone else jumps in, like Jan for your other awesome tickets.

Anyway, awesome work !

Thanks for all, Harald


serhiy.storchaka added on 2026-09-17 10:42:53:

Yes, the binding is unchanged: bind . <Control-v> "puts {Ctrl+V}" (I use the V key in the examples below instead of C, because Latin "C" and Cyrillic "С" look the same and are easy to confuse).

On a Ukrainian keyboard the physical key has both "V" and "М" (Cyrillic em) printed on it. Windows keeps the virtual key code VK_V for that key in every layout; the fix uses that Latin letter as the keysym only when Control or Alt is held, so <Control-v> now matches Ctrl+М, as paste does in other Windows applications.

Pressing the key alone is not affected: %A is м as before, and %K is still ?? on Windows, because TkpGetKeySym() returns the raw Unicode code point (U+043C), which is not a valid keysym (Cyrillic_em is 0x6CD). So bind . <Cyrillic_em> still does not fire on Windows — that is the separate "Cyrillic keysyms in bind" issue you raised in 2019. It is the same in 8.6 and 9.x (in 9.x <м> is also accepted, but maps to 0x100043C, which the Windows code never produces). It is out of scope for this fix; it could be a follow-up ticket.

On X11 the situation is different: the keysym comes from the active keyboard layout, so Ctrl+М gives Cyrillic_em and <Control-v> does not match there either. That needs a separate fix in unix/tkUnixKey.c (fall back to the Latin keysym of the first group when Control or Alt is down). Should it be included in this branch, or done as a separate branch/ticket?

I have added a paragraph about the new behavior to the bind man page.


oehhar added on 2026-09-17 08:01:46:

Thanks, great, even a test present.

Would it possible to add some text to the bind man page about this?

And a question for me:

Ctrl+C:

is the binding still:

bind . <Ctrl+c> "puts {Ctrl+C}"

What is written on the c-key?

What happens, if you just press the c key?

Thanks for all, Harald


serhiy.storchaka added on 2026-09-16 18:18:07:

With Control or Alt held, TkpGetKeySym() in win/tkWinKey.c returned the character of the key in the current layout as the keysym. With a non-Latin layout it is not a valid keysym (%K is ??), so bindings like <Control-c> never matched.

Fixed on branch win-nonlatin-shortcuts in [3eafc907b3]: the Latin letter or digit of the virtual key code is used instead, as other Windows applications do. The typed character (%A) is unchanged, so mnemonics with non-Latin labels keep working. Verified with the Ukrainian layout on Windows 11.


oehhar added on 2019-05-30 08:27:59:

Yes, I suppose we have first to fix the binding bug for "Cyrillic_tse". To install the bindings in a second step might be not so difficult.

So analysis is done, fixing is pending. I will probably not care due to lack of time.

Thank you, Harald


anonymous added on 2019-05-29 11:32:21:
Very quick follow-up from my side: 

1) on macOS, Russian keyboard layout, copy&paste works fine with the usual shortcuts.
2) on Windows, the problem is not limited to Russian. I can reproduce the same problem with at least Greek and Ukrainian
3) % bind . <Cyrillic_tse> {puts "Cyrillic tse key"} does not produce any effect, no matter which keys I try to hit

oehhar added on 2019-05-27 19:49:50:

Here are the valid key syms for 8.6:

http://www.tcl.tk/man/tcl8.6/TkCmd/keysyms.htm

I suppose, "Cyrillic_tse" is the glyph corresponding to the lattin c key.

So lets try:

% bind . <Cyrillic_tse> {puts "Cyrillic tse key"}

No error message in binding but no event for me.

Could you verify that ?

Thank you, Harald


oehhar added on 2019-05-27 17:32:47:

Thank you for the test. I have added russian keyboard to my german Windows 10.

I can reproduce your issue.

The keyboard works within Tk Widgets and within the console. But the bind %K substitution returns "??".

I also tested some special characters on my German keyboard and they return sensible ASCII-representations of the character:

  • äöüÄÖÜ : adiaeresis, odiaeresis, udiaeresis, Adiaeresis, Odiaeresis, Udiaeresis
  • ß : ssharp

IMHO we have a bug/issue in the bind mechanism to not return valueable value.

Now try to bind to the russian characters:

% bind . <с> {puts "Russian c key"}
bad event type or keysym "с"
% bind . <м> {puts "Russian v key"}
bad event type or keysym "с"

So I would tend to extend this ticket to "Russian keysims not working in bind".

Can anybody check if this works on Linux or MacOS ?


anonymous added on 2019-05-27 16:02:14:
I am sorry I will not be very helpful: the Wish console seems not to be able to correctly display the values if a switch my keyboard to Russian. I get:

<Control_L>
<??>

I am not aware of any settings I can change to allow other character settings being displayed correctly.

Please note that I am working with an English Windows (simply switching keyboard layout in Windows). I am now using ActiveTcl, latest version.

oehhar added on 2019-05-25 14:46:38:

Ok, there are probably Bindings missing.

Could you please execute the following script to find out the bindings and report them here:

bind . <Key> {puts {<%K>}}

Fro my latin keyboard, it is:

<Control_L>
c
<Control_L>
v

Thank you, Harald


anonymous added on 2019-05-23 10:26:22:
Hello Harald,

if I switch the layout to Russian, for example, Ctrl+c and Ctrl+v do not invoke any action in all Widget I tried. It does not matter if it is between two widgets or between Tk and an external application. It works with the alternative shortcuts: Control+Insert = Copy and Shift+Insert = Paste. I guess the reason is that copy and paste is invoked if the "letters c/v" are used, but these are not available on non-latin keyboards. Normally, however, in Russian and co. copy and paste is invoked with the (physical) keys which are normally occupied by c/v in latin keyboards. I guess most applications bind, therefore, the physical code of the key and not the character represented by it.

Please, also see the following forums, talking about the problem 

https://bugs.python.org/issue31244

https://stackoverflow.com/questions/40946919/python-tkinter-copy-paste-not-working-with-other-languages

I do not now if it is a bug or a feature, but I think it is strange I need to create an ad-hoc solution (listening to pressed key) to allow copy and paste on non-latin keyboards. You can simply replicate it adding a language layout to the Windows installation.

oehhar added on 2019-05-22 06:40:49:

Thank you for your report.

What exactly do you mean with "does not work" ? Some possibilities:

  • The shortcut keys "CTRL+c" and "CTRL+v" do not invoke copy and paste?
  • The copied data is replaced by something else when copying within two tk widgets. Example: Text widget contents: "АБВГҐДЂ", copied contens: ":lK6(7$5"
  • Same as above, but to an external application (Windows Editor)
  • Same as above, but from an external application (Windows Editor)

Thank you and best regards, Harald