Key Codes for QWERTY phones j2me - java-me

I'm currently doing a j2me project, and I am wondering what key code I will use for the keylistener when I press letters like A, B, C, etc?
I'm deploying the j2me in a QWERTY phone - SAMSUNG CH#T 223.

On Canvas.keyPressed the keyCode parameter will hold the Unicode value of the corresponding character of the pressed key.
Depending on the keyboard mode the value might vary. For example, the same key might generate 'd', 'D' or '4'.
The modes are: normal (lower case letters), shift/caps (high case letters) and alt (numbers and symbols).

Related

What single word does a programmer call the control and command keys?

The control and command keys are basically analogs when it comes to computer applications, when I'm talking about them in a cross-platform application, what should they be called? Is there a term like " the _______ key"?
Alt / Shift / Control / Command - they're all modifier keys. Ctrl/Command are analogs in the sense that they're used for "command"-type shortcuts, i.e. performing some action. Maybe a C-modifier key or action-modifier key would be the right names.
"Modifier key" is the term at least used many online dictionaries and documentation. (Including Apple and IBM.) (As used but not quite advocated in ALGOholic's answer.)
FYI there is an old term that has been used: "bucky (bit) keys". From The Hacker's Dictionary:
BUCKY BITS noun.
Control characters are so useful that sometimes special keyboards
are built that have even more shift keys. One of the first of these was
used at Stanford. It had the usual shift and control keys, and a third
key called "meta", as well as lots of unusual characters such as Greek
letter. So, one can type such characters as control-F, meta-N, and
control-meta-B.
Now, when you type a character on a Stanford keyboard, the
following information is sent to the computer: a code indicating the
basic character, plus one BIT for each shifting key to indicate whether
that shifting key was pressed along with the basic character key.
Programs usually treat the regular shift key as part of the basic
character, indicating whether you want lower case or upper case (or
whether you want "3" or "#", and so on). The other bits (control and
meta) are called the bucky bits.
(Observe that the source itself refers to "shift keys" and "shifting keys".
See also the jargon file glossary:
bucky bits: /buh'kee bits/, n.
[obs.] The bits produced by the CONTROL and META shift keys on a SAIL keyboard [...] (see space-cadet keyboard).
By extension, bits associated with ‘extra’ shift keys on any keyboard, e.g., the ALT on an IBM PC or command and option keys on a Macintosh.
Observe that the source itself refers to the bucky keys as "‘extra’ shift keys".
(I observe that "Bucky bits" & "space cadet keyboard" are referenced in the Wikipedia entry for "modifier key". Unfortunately, there isn't an etymology for "modifier key" itself.)

How to find which key is pressed, not which character it will be?

I need to find out which key was pressed, not what character it would be.
For example, I want after pressing 'a' a number such (1) create so I can map it to other languages. In common way we can find it is 'a' or we can have it's hash code, but is it possible to have char or hash code in a language and find out what char or hash code it would be in another language?
Attention some language have not the standard keyboard so pressing a key not mean a certain character.
There's no reason to do this in any language i've seen.
(besides the fact that you didn't specify in which language you are trying to achieve this)
All languages allow you to get the character code from a keypress.
If you know which encoding was used (UTF 8, Ascii, you name it), it's trivial to map the code to the actual character.
Assigning a different keyboard layout on OS level means that it no longer matters which keyboard layout you are using.
if you have a QWERTY keyboard, switch it to AZERTY and press the button where the q would be, you get an a, despite the letters on the keyboard still saying QWERTY.
If you are using a chinese keyboard, the characters no longer map to any western set, so the character codes will not match up with UTF8 or ASCII, but CP963 (or another chinese codepage, depending on several factors), which is so different there is no real way to translate it to UTF8 or ASCII.

Binary Keyboard Layout

I've recently informed myself a bit about keyboard layouts and tried things like Dvorak or Neo, but today i asked myself the question wether there is a sort of 'binary' keyboard layout.
It should use 8 keys to key in the binary representation of one character (one byte).
Example:
ASDF and JKL; are used for input.
If want to write an 'A' (65 decimal, 10000001 binary)
you had to press A and ;
Or you wanted to write an 'f' (146 decimal, 10010010 binary)
you had to press A, F and L.
I wondered if there was already something like this or somebody could show me a C/C++ library capable of altering the keaboard layout and supporting combinations like these.

Keyboard returns wrong keycode for Latin characters

I am writing an application that handles key presses using DirectFB v1.4.2 / Linux keyboard driver. I am receiving key codes with wrong values for Latin characters. On pressing character 'a' in USB keyboard, I receive a Unicode value of '0xF601'. But, it seems the Unicode value of Latin character 'a' is different. Please let me know what is going wrong here. Is there any specific setting required to be set in DirectFB?
Thanks in advance.

Keyboard remapping with more modifiers

I'm looking for a way to add one more "layout" to my keyboard. I'm already using a layout that uses altgr for local alphabet letters. What I'd like to add is a mirrored righthand-side keyboard that's activated with the caps-lock (one described in http://xkcd.com/mirrorboard.xkb)
Unfortunately ISO_LEVEL3_SHIFT is already taken by local alphabet. (AFAIK) If I use mode_shift to change groups I cannot use more than 2 levels in a group anymore. Is there a way to create different groups for both altgr and mode_shift?
For each keycode definition you can have up to eight keysyms. These are organized pairwise into four groups. There is a family of keysyms ISO_Next_Group, ISO_Prev_Group, ISO_First_Group, and ISO_Last_Group that, when pressed, cycle the keysym output by striking the key among the keysym groups. These keys are how you attain multiple layouts.
As an example, assuming ISO_Next_Group has been bound to a keycode and assigned to a modifier, then for this definition:
keycode 53 = x X Greek_xi Greek_XI multiply U2297 U24E7 U24CD
pressing my keyboard key with the label “X” on types out “x”. After pressing the ISO_Next_Group key, I get “ξ”. Pressing it again, I get “×”. Pressing it again, “ⓧ”. Finally, pressing it a fourth time gets things back to normal.
Having spend several days (because Xkb¹ has horrible documentation; finally found an okay guide here), you can create a symbol definition file with entries like this:
key <SPCE> {
// Level I II III IV
[ space, space, U2395, U2592 ], // Group 1
[ U2423, emspace, U2420, hairspace ] // Group 2
};
key <RALT> {
[ Mode_switch, Mode_switch ]
};
key <RCTL> {
[ ISO_Level3_Shift, ISO_Level3_Shift ]
};
The brackets enclose a single group. Normally, the first group is active. The group can be temporarily incremented by one with ISO_Group_Shift, a.k.a. Mode_switch. Within a group, the symbols emitted are defined in increasing levels. Level I is with a bare keypress. Shift adds one to the current level. ISO_Level3_Shift sets the level to III.
The example above maps seven symbols to the space bar plus various shift keys such that:
space ⟨ ⟩ U+0020 SPACE
Shift+space ⟨ ⟩ U+0020 SPACE
R. Alt+space ⟨␣⟩ U+2423 OPEN BOX
R. Alt+Shift+space ⟨ ⟩ U+2003 EM SPACE
R. Ctl+space ⟨⎕⟩ U+2395 APL FUNCTIONAL SYMBOL QUAD
R. Ctl+Shift+space ⟨▒⟩ U+2592 MEDIUM SHADE
R. Alt+R. Ctl.+space ⟨␠⟩ U+2420 SYMBOL FOR SPACE
R. Alt+R. Ctl.+Shift+space ⟨ ⟩ U+200A HAIR SPACE
There is also a key ISO_Level5_Shift for level V. So you can have at least six symbols for one group. With the mode shift key this implies that you can configure your keyboard to type out approximately 1,200 distinct symbols, but at that point holding down so many modifiers will likely deaden a few keys.
P.S. The names of all the named symbols are stored in /usr/include/X11/keysymdef.h.
¹ Turns out that xmodmap(1) is buggy and deprecated.

Resources