Skip to content

keyCode for Android #1635

Closed
Closed

Description

@transfluxus

The keycodes generated by the android keyboard do not match with the constants in PConstants.
I didn't check all but at least the keyCode of backspace is not 8 (as BACKSPACE) but 67.

Activity

  1. benfry commented on Feb 19, 2013

    @benfry
    Contributor

    What is 'key' in those cases? With any luck, it's BACKSPACE.

  2. transfluxus commented on Feb 26, 2013

    @transfluxus
    Author

    the key for BACKSPACE is ï¿¿

    import android.view.inputmethod.InputMethodManager;
    import android.content.Context;

    boolean displayKB=true;

    void setup() {
    background(0);
    showVirtualKeyboard();
    fill(255);
    textSize(20);
    }

    void draw() {
    }

    void mousePressed() {
    displayKB = !displayKB;
    if (displayKB)
    showVirtualKeyboard();
    else
    hideVirtualKeyboard();
    }

    void keyPressed() {
    background(0);
    text(key, 10, 40);
    println(key);
    if (key == CODED) {
    println(keyCode);
    if (keyCode == BACKSPACE)
    text("BACKSPACE?", 10, 40);
    else
    if (keyCode == 67)
    text("BACKSPACE!", 10, 40);
    }
    }

    void showVirtualKeyboard() {
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
    }

    void hideVirtualKeyboard() {
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
    }

  3. processing-bugs commented on May 14, 2013

    @processing-bugs
  4. github-actions commented on Jun 16, 2021

    @github-actions

    This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  5. locked as resolved and limited conversation to collaborators on Jun 16, 2021
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions