Skip to content

keyboard type #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
OussamaAlouat opened this issue Jul 25, 2018 · 11 comments
Closed

keyboard type #65

OussamaAlouat opened this issue Jul 25, 2018 · 11 comments
Labels
Question General questions about the library

Comments

@OussamaAlouat
Copy link

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.

@dkrutsko
Copy link
Member

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);.

@dkrutsko dkrutsko added the Question General questions about the library label Jul 25, 2018
@OussamaAlouat
Copy link
Author

OussamaAlouat commented Jul 26, 2018

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?

@dkrutsko
Copy link
Member

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.

@OussamaAlouat
Copy link
Author

OussamaAlouat commented Jul 31, 2018

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?

@dkrutsko
Copy link
Member

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?

@OussamaAlouat
Copy link
Author

The second one, I want to retrieve every key's states.
Thanks.

@dkrutsko
Copy link
Member

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.

@OussamaAlouat
Copy link
Author

OussamaAlouat commented Aug 2, 2018

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.

@dkrutsko
Copy link
Member

dkrutsko commented Aug 2, 2018

Honestly, that function just redirects to GetAsyncKeyState. Hopefully the Microsoft documentation can provide the answer you're looking for.

@OussamaAlouat
Copy link
Author

OussamaAlouat commented Aug 6, 2018

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 output is:
captura

@dkrutsko
Copy link
Member

dkrutsko commented Aug 7, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question General questions about the library
Development

No branches or pull requests

2 participants