From: andandgui isler on
i want to type the keycode of ALT key to matlab by using java but i don't find the keycode. Also i don't find the bracet or question mark keycode ?

Where i can find them
From: Matt Fig on
java.awt.event.KeyEvent.VK_ALT
From: Walter Roberson on
andandgui isler wrote:
> i want to type the keycode of ALT key to matlab by using java but i
> don't find the keycode.

Keycodes depend upon the keyboard you are using.

If you are using a Microsoft Windows Logo certified keyboard, then the
keyboard will emit Scan Code 2 compatible codes, but the keyboard driver will
convert those into Scan Code 1 codes which is what is used by the OS.

ALT pressed in conjunction with a key will have a different key code than ALT
by itself. Left ALT and Right ALT have different key codes. Pressing a
character has a different key code than releasing the character.

The following is valid only for PS/2 scan codes; USB keyboards use different
scan codes.

Below, 0x followed by a pair of characters indicates the what follows is
hexadecimal; e.g., 0x0D would be decimal 13

Left Alt:
Scan Code 2: press = 0x11, release = 0xF0 0x11
Scan Code 1: press = 0x38, release = 0xB8

Right Alt:
Scan Code 2: press = 0xE0 0x11, release = 0xE0 0xF0 0x11
Scan Code 1: press = 0xE0 0x38, release = 0xE0 0xB8


> Also i don't find the bracet or question mark
> keycode ?
> Where i can find them


( is shift-9, and in Scan Code 2, shift needs to be sent as an individual
code. Which code depends upon which shift. The release events for the 9 and
the shift are sent separately in Scan Code 2, according to which one is
released first. The scheme differs for Scan Code 1 (used internally, possibly
what you have to generate): a code for the shift still has to be sent, but
when the second key is pressed, a sequence of codes has to be sent, and when
one of the two keys is released, a sequence of codes has to be sent that
differs according to which of the two is released first, essentially signally
which of the keys is still pressed. This all gets messy so I'll point you to
the documentation:

http://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-923143f3456c/scancode.doc
From: andandgui isler on
Thanks for replies..
now i have the problem with
question mark
and some special characters like Ö Ü

how can i press them using MATLAB.. i write code of other keys but i cant find these keys code or any alternative method to press them.
what should i do
From: Walter Roberson on
andandgui isler wrote:

> now i have the problem with
> question mark
> and some special characters like Ö Ü
>
> how can i press them using MATLAB.. i write code of other keys but i
> cant find these keys code or any alternative method to press them.
> what should i do

question mark is shift / and so follows similar rules to what I
described before with respect to ( .

Ö Ü need modifier keys to enter.

In terms of the java sequences Matt hinted at:

http://java.sun.com/j2se/1.4.2/docs/api/java/awt/event/KeyEvent.html

( is VK_LEFT_PARENTHESIS
) is VK_RIGHT_PARENTHESIS
Ö seems to be VK_DEAD_ABOVEDOT VK_O
Ü seems to be VK_DEAD_ABOVEDOT VK_U

"Not all characters have a keycode associated with them. For example,
there is no keycode for the question mark because there is no keyboard
for which it appears on the primary layer."

and that implies that question-mark is VK_SHIFT VK_SLASH

And remember to generate the appropriate VK_KEYPRESSED and
VK_KEYRELEASED events (I guess... I don't know what would happen if you
just entered one of the VK_* without a VK_KEYPRESSED )