openframeworks / openframeworks/openFrameworks

Android keyPressed for volume buttons always sets key = 0

Open
#2,418 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

android bug
Dominant language
C++
Stars
10.4k
Forks
2.6k
Avg merge
1d 21h
Merged PRs (30d)
9

Description

When a keyPressed event is received for pressing a menu button, the key passed in is always 0. This is because event.getUnicodeChar() returns 0 for keys that are not used to type characters, which includes most of the physical keys on a typical touchscreen-based Android phone.

One solution would be to have the Android wrapper define some "special" keys (negative numbers to avoid conflicting with Unicode codepoints? numbers with a high-ish bit, like bit 28, set?), and pass those in when the key is special (volume, home, menu, etc).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the Android wrapper's keyPressed handling and inspect where event.getUnicodeChar() supplies the key value. Review how non-character keys such as volume, home, and menu are represented, then verify that these events produce distinct nonzero key values without conflicting with Unicode codepoints.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, cpp
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.