Where i can find them
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
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 )
Thanks for your attention Walter Roberson.
The problem still countinues. When i type the code below :
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
keyboard=Robot;
>> keyboard.keyPress(KeyEvent.VK_DEAD_ABOVEDOT VK_O);
??? keyboard.keyPress(KeyEvent.VK_DEAD_ABOVEDOT VK_O);
|
Error: Unexpected MATLAB expression.
gives this error and also
>> keyboard.keyPress(KeyEvent.VK_SHIFT VK_SLASH)
??? keyboard.keyPress(KeyEvent.VK_SHIFT VK_SLASH)
|
Error: Unexpected MATLAB expression.
> import java.awt.AWTException; import java.awt.Robot; import
> java.awt.event.KeyEvent; keyboard=Robot;
>>> keyboard.keyPress(KeyEvent.VK_DEAD_ABOVEDOT VK_O);
> ??? keyboard.keyPress(KeyEvent.VK_DEAD_ABOVEDOT VK_O);
> |
> Error: Unexpected MATLAB expression.
keyboard.keyPress.KeyEvent.VK_DEAD_ABOVEDOT;
keyboard.keyPress.KeyEvent.VK_O;
The KeyEvent method takes only a single keycode.
this is the wrong syntax, though...
it should read
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
kbd=Robot; % <- don't use KEYBOARD as a var...
kbd.keyPress(KeyEvent.VK_DEAD_ABOVEDOT); % <- see below...
kbd.keyPress(KeyEvent.VK_O); % <- this works...
% however, this does NOT always work...
kbd.keyPress(KeyEvent.VK_DEAD_ABOVEDOT);
%{
??? Java exception occurred:
java.lang.IllegalArgumentException: Invalid key code
at sun.awt.windows.WRobotPeer.keyPress(Native Method)
at java.awt.Robot.keyPress(Unknown Source)
%}
us
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
kbd=Robot;
kbd.keyPress(KeyEvent.VK_DEAD_ABOVEDOT);
??? Java exception occurred:
java.lang.IllegalArgumentException: Invalid key code
at sun.awt.windows.WRobotPeer.keyPress(Native Method)
at java.awt.Robot.keyPress(Unknown Source)
kbd.keyPress(KeyEvent.VK_O);
>> o
kbd.keyPress(KeyEvent.VK_O) works but,
kbd.keyPress(KeyEvent.VK_DEAD_ABOVEDOT) doen't work on my computer
well, yes...
that's EXACTLY what i said in my reply: this solution does not work...
us
>
> kbd.keyPress(KeyEvent.VK_O) works but,
> kbd.keyPress(KeyEvent.VK_DEAD_ABOVEDOT) doen't work on my computer
http://www.w3.org/2002/09/tests/KeyEventDemo.java
is a demo that will show you key presses and releases, so you could use
that to query what any particular key sequence becomes.
as i said: this approach does not work from within genuine ML (at least in wintel envs)...
just look at my replies...
us
That isn't immediately clear, as the demo might show a completely
different key sequence; or plausibly if run until Matlab, the demo would
show the key sequences that Matlab wants.
For example, plausibly the demo would show the VK_DEAD_ABOVEDOT *after*
the vowel -- since, after all, Matlab did not complain that
VK_DEAD_ABOVEDOT was an invalid field or method.
yes it does, walter
look in my replies above to see the error message it pukes...
us
Looking around, it appears that this is a common Java Robot problem not
specific to Matlab. The discussion I found at
https://bugs.eclipse.org/bugs/show_bug.cgi?format=multiple&id=280562
hints that the work-around is to code each key press literally, such as
VK_CONTROL VK_RIGHT_ALT VK_SHIFT VK_QUOTE VK_O
and then the release events for those in the opposite order. (I do not
have a PC available to test the exact key sequence with.)
By the way: the discussions above show the problem being debugged by use
of the exact demo that I pointed to...