Skip to content

PySDL2 example: pressing Enter inserts newlines instead of submitting the form #703

Open

Description

@cztomczak

When running examples/pysdl2.py, pressing Enter in Google’s search input inserts a newline instead of submitting the search. Repeated Enter presses keep expanding the input field, as shown in the attached screenshot.

Proabable cause: the example’s handle_key_event() sends KEYEVENT_CHAR for Enter but does not send KEYEVENT_RAWKEYDOWN. This may prevent web pages from handling Enter as a key press.

OS: Ubuntu 24

Image

Activity

  1. linesight commented on Oct 25, 2026

    @linesight
    Contributor

    Could you review this isolated fix for Enter in the PySDL2 example? Commit c490d1e
    Branch diff

    It sends KEYEVENT_RAWKEYDOWN before the existing KEYEVENT_CHAR, allowing Google’s Enter handler to submit the search and prevent a newline.

    I tested the unmodified v66.1 example against Google on Windows. With CEF 66, Google serves a single-line <input> and Enter submits. The same example with CEF 147 receives a <textarea> and inserts a newline. Adding the missing keydown restores search submission with CEF 147.

    If this looks good to you, I'll cherry-pick this single commit into the PR branch.

  2. cztomczak commented on Oct 25, 2026

    @cztomczak
    OwnerAuthor

    Thanks, this fixes the missing keydown for Enter. I noticed that printable keys from SDL_TEXTINPUT are sent as KEYEVENT_CHAR, but their corresponding SDL_KEYDOWN events are ignored. Could you also send KEYEVENT_RAWKEYDOWN for printable key presses, while keeping SDL_TEXTINPUT responsible for KEYEVENT_CHAR? This would let pages receive normal keydown events for letters as well.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions