keyboard type
OussamaAlouat opened this issue · 11 comments
Hello! I need to change the layout of the keyboard for the project I'm currently working.
I need a Spanish keyboard. Would it be possible?
Thanks in advance.
I'm not sure I understand your question. The constants are consistent with what the operating system provides. If a particular constant is not provided by robot, you can simply create whatever constant you need. For example: keyboard.click (96);
.
The problem is that I need record when someone press some keys. I need store the keys pressed in a Spanish keyboard and Robotjs doesn't provide codes for 'ñ' or 'ALT GR' keys that are present in that kind of keyboard.
Is there some way to store codes for keys pressed in different layouts or create my own equivalences in Robotjs?
See if you can use GetState
with the number representing ñ
, 164 or 165 I think. I'm not completely sure how these characters work on Windows, but someone mentioned scan codes which I'll look into implementing.
Hello again.
I read in the docs that GetState checks the pressed state of all keys system-wide. The point is: on Windows when I start my application and I call GetState in the first line, the result is an object with some keys pressed... (my expectations were no key pressed).
How can it be? There are something that I am not understanding?
There's two versions of the function, one where you pass to it a key, and another where you pass nothing and it returns an array of all keys. Which keys does it say are being pressed?
The second one, I want to retrieve every key's states.
Thanks.
Yeah I think at the moment, you need to do what I suggested above, and enter your keys manually for keys not supported by robot. It's the only thing that will solve your problem immediately and is basically how the array version of the function works.
Ok, from the beginning. I am developing a multiplatform application and I am using the second version of getState method to record every key pressed or released. On linux, all works as expected, but on Windows is different. For example, when I press the CTRL KEY, sometimes I recive two codes (17 & 162) but other times I recive only one (17).
Is this a normal behaviour on Windows? I don't think so but I don't understand why it is happening this?
NOTE: I want to clarify that problem only happens on Windows. My tests on Linux works perfectly.
Honestly, that function just redirects to GetAsyncKeyState. Hopefully the Microsoft documentation can provide the answer you're looking for.
Hello again.
In this case, I'm trying to write the '<' symbol on Windows using your library, but I don't know which code is. So, first I did console.log(robot.Keyboard.compile('{<}'));
and the output shown in console was: [ { down: true, key: 8 }, { down: false, key: 8 } ]
, so I suposed the code to write '<' symbol is 8.
However, when I do robot.Keyboard().click(8);
or robot.Keyboard().press(8); robot.Keyboard().release(8);
nothing is shown in the console. What am I doing wrong? Why is the code not written as expected? Is this something normal?
I did this:
console.log(robot.Keyboard.compile('<')) // Output: [ { down: true, key: 8 }, { down: false, key: 8 } ]
robot.Keyboard().click(8);
robot.Keyboard().press(8);
robot.Keyboard().release(8);
The <
key represents backspace, see the table on this page for more. If you want to press the <
key, you actually have to press shift
+ ,
. That's how you would press it on a regular US keyboard. I'm not sure if that key is different on non-US keyboards. I think I mentioned this above but on Linux, the keys are based on scan keys, which is really the way I should be handling it on Windows as well, but that'll most likely get supported in a future version of robot.