Skip to content

A bug when bind <F3> shortcut key in the Tkinter program. #146030

Closed as duplicate

Description

@thefatwhale

Bug report

Bug description:

On the Windows 10, if you input an "r" using the Chinese PinYin input method. then press the Enter key to display the English "r" on the text box, it will trigger the F3 input event.

also on IDLE (It is also a built-in program developed based on tkinter).
When using the idle program, if you input "r" and make it appear on the screen, it will cause the "Find and Replace" dialog box to be displayed. Equals to Press the F3 key.

this is minimal example code of this bug.

test on:
Windows 10 + Python 3.10.11
Windows 10 + Python 3.14.3

# minimal example code

import tkinter as tk

def on_f3_press(event):
    print("-" * 30)
    print("【trigger】F3 event!")
    print(f"keysym: {event.keysym}")
    print(f"char: {event.char}")
    print(f"keycode: {event.keycode}")
    print(f"type: {event.type}")
    print("-" * 30)


# 创建主窗口
root = tk.Tk()
root.title("Tkinter F3 Bug 复现测试")
root.geometry("400x400")

# 创建一个输入框
entry = tk.Entry(root, width=50, font=("Arial", 14))
entry.pack(pady=20, padx=20)

# 创建一个文本区域
text = tk.Text(root, height=10, font=("Arial", 12))
text.pack(pady=10, padx=20)

# 核心关键:绑定 F3 快捷键
# 我们在根窗口级别绑定,这样无论焦点在哪都能捕获
root.bind("<Key-F3>", on_f3_press)

label = tk.Label(root, text="请使用输入法在框中输入字母 'r' 并回车上屏。\n如果控制台打印了信息,则说明 Bug 复现成功。", wraplength=350, justify="left")
label.pack(pady=20)

root.mainloop()
python demo.py

use IME such as Chinese input method on Windows

------------------------------
【trigger】F3 F3 event!
keysym: F3
char: r
keycode: 114
type: 2
------------------------------

CPython versions tested on:

3.14

Operating systems tested on:

Windows

Activity

  1. added
    type-bug
    on Mar 16, 2026
  2. thefatwhale commented on Mar 16, 2026

    @thefatwhale
    Author
    Image

    I have no idea, why only char r causes this bug. It results in an F3 keyboard key event being inputted.

    Image
  3. added
    stdlib
    on Mar 16, 2026
  4. thefatwhale commented on Mar 16, 2026

    @thefatwhale
    Author

    also on IDLE (It is also a built-in program developed based on tkinter).

    When using the idle program, if you input "r" and make it appear on the screen, it will cause the "Find and Replace" dialog box to be displayed. Equals to Press the F3 key.

    Image Image
  5. StanFromIreland commented on Mar 16, 2026

    @StanFromIreland
    Member

    I cannot reproduce this on Linux in IDLE.

  6. Locked-chess-official commented on Mar 17, 2026

    @Locked-chess-official
    Contributor

    It might be the bug for tk on windows.

  7. ThingamabobsCoding commented on Mar 26, 2026

    @ThingamabobsCoding

    This bug is sadly very old. I think it was resolved with full unicode-support in tcl / tk 9. You can look here

    #125349 (comment)

  8. thefatwhale commented on Mar 27, 2026

    @thefatwhale
    Author

    Yes, this is indeed an old issue, and I remember it existed even when using python3.8

    The issue you referenced is indeed the same one I'm facing. Thanks!

    #125349

  9. thefatwhale commented on Mar 27, 2026

    @thefatwhale
    Author

    Should I close this issue?

    Because it was duplicated with that issue

  10. ThingamabobsCoding commented on Mar 27, 2026

    @ThingamabobsCoding

    Maybe @StanFromIreland can answer that question. I don't know

  11. Wulian233 commented on Mar 27, 2026

    @Wulian233
    Contributor

    #125349 (comment)

    This issue has persisted. I made some additions a year ago and there are also solutions available

  12. thefatwhale commented on Mar 27, 2026

    @thefatwhale
    Author

    @Wulian233

    Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-windowsstdlibtopic-tkintertype-bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions