Skip to content

Typing some characters in P2D won't return what character was pressed with keyPressed in Processing 4.3 #824

Closed

Description

@processing-bot

Created by: bugreporter0

Description

Expected Behavior

"< was pressed" should be written in the console

Current Behavior

keyPressed detects that a character was typed but not which one when "<" is typed

Steps to Reproduce

Works:

void setup()
{
  size(400, 400);
}

void draw()
{
}

void keyPressed()
{
  if(key == '<')
    println("< was pressed");
}

Doesn't work:

void setup()
{
  size(400, 400, P2D);
}

void draw()
{
}

void keyPressed()
{
  if(key == '<')
    println("< was pressed");
}

Your Environment

  • Processing version: 4.3
  • Operating System and OS version: both windows (10, 11) and Ubuntu 22.04
  • Other information:

Possible Causes / Solutions

Maybe some characters have been forgotten in the keyPressed P2D API in Processing 4 and above because it worked in the last Processing 3 version, I've checked

Activity

  1. processing-bot commented on Feb 26, 2024

    @processing-bot
    CollaboratorAuthor

    Created by: bugreporter0

    I'm sorry for the weird behavior, I'm new to GitHub and I don't know English very well

  2. processing-bot commented on Feb 26, 2024

    @processing-bot
    CollaboratorAuthor

    Created by: Hellcat554

    I really don’t know what I am doing I’m trying to learn new things I new to
    the community in just want to learn….

    On Sun, Feb 25, 2024 at 8:31 PM bugreporter0 @.***>
    wrote:

    I'm sorry for the weird behavior, I'm new to GitHub and I don't know
    English very well

    —
    Reply to this email directly, view it on GitHub
    https://gitlab.com/Stefterv/processing4/-/issues/824#issuecomment-1963213850,
    or unsubscribe
    https://github.com/notifications/unsubscribe-auth/BGCSUAIGZEWUBIBKIY27HU3YVPXYDAVCNFSM6AAAAABDZMBDBOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRTGIYTGOBVGA
    .
    You are receiving this because you are subscribed to this thread.Message
    ID: @.***>

  3. added
    bug
    on Nov 16, 2024
  4. Stefterv commented on Nov 16, 2024

    @Stefterv
    Member

    @bugreporter0 What is the key combination you have to press to get the < character on your OS's?

    benfry/processing4#824

  5. pinkandwhiteandblack commented on Nov 19, 2024

    @pinkandwhiteandblack

    I'm bugreporter0.

    My keyboard has this character as a key, it's a standard AZERTY full size keyboard. The "<" character is next to the left SHIFT key.

    "<" is not the only missing character, it's just an example.

  6. SableRaf commented on Nov 19, 2024

    @SableRaf
    Collaborator

    Hi @pinkandwhiteandblack

    The keyPressed documentation page includes this note:

    For non-ASCII keys, use the keyCode variable.

    See https://processing.org/reference/keyPressed_.html

    You can find the key code for any key by using a tool like https://www.toptal.com/developers/keycode

  7. pinkandwhiteandblack commented on Nov 19, 2024

    @pinkandwhiteandblack

    The keyCode variable should be set to 60 when I press "<" but println(keyCode) prints "0" in the console when I do, confirming that there really is a problem.

    Code:

    void setup()
    {
      size(400, 400, P2D);
    }
    
    void draw()
    {
    }
    
    void keyPressed()
    {
      println(keyCode);
    }
    

    Important: it works in the default render (with keyCode 153 instead of 60 but whatever) but not in P2D.

    Also, the"Alt Gr" key on my keyboard returns two keyCodes: 17 then 18 when I press it just once.

  8. added
    help wanted
    on Jan 14, 2025
  9. SableRaf commented on Mar 25, 2025

    @SableRaf
    Collaborator

    Worth checking if this is fixed by #966 (cc @Rishab87)

    If not, this could be a test too :)

  10. Rishab87 commented on Mar 25, 2025

    @Rishab87
    Contributor

    Yes it is also fixed by #966
    Image

  11. SableRaf commented on Mar 25, 2025

    @SableRaf
    Collaborator

    Great! Thanks @Rishab87 ✨

  12. pinkandwhiteandblack commented on Jun 11, 2025

    @pinkandwhiteandblack

    The issue is still present in 4.4.4 on Windows 10

  13. SableRaf commented on Jun 11, 2025

    @SableRaf
    Collaborator

    Hi @pinkandwhiteandblack

    Just tested this on Windows 10 with a QWERTY keyboard using Processing 4.4.4. Pressing < works as expected in P2D.

    I don’t have access to an AZERTY keyboard right now, so I can’t test that setup directly.

    To help us narrow this down, could you share a few more details?

    • Your keyboard layout and language
    • The key combo you press to get “<”
    • Any input method or keyboard remapping tools you're using
    • The full sketch you're running (if it's different from the one in the original post)

    If it turns out to be layout-specific, we can reopen this or open a new issue with those details.

    Image

  14. pinkandwhiteandblack commented on Jun 11, 2025

    @pinkandwhiteandblack

    Image

    • This layout in french, the key is between "left shift" and "W".
    • I'm not using any remapping tool
    • This sketch (the original):
    void setup()
    {
      size(400, 400, P2D);
    }
    
    void draw()
    {
    }
    
    void keyPressed()
    {
      if(key == '<')
        println("< was pressed");
    }
    

    It's probably layout-specific because it works when I use a QWERTY keyboard.

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

    bugcorehelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions