i would like to build a cheap USB Rubber Ducky by myself. this is a rubber ducky
I've got an Arduino Leonardo and it should perform different commands on a Windows Machine.
All works fine, except Special German Characters. I can't perform the keys @ , { , [ , ] , } because i need the ALT_GR Key on the Keyboard. Does anybody has a Solution to use the keyboard.h library with a German Keyboard Layout and enable the Usage of the right ALT-Key as the german ALT_GR Key?
e.g.: For the @-character i would need the ALT_GR Key + "q"...
If i change the Keycodes in the keyboard-.h like before for other keys, it won't work, because the library doesnt recognise the ALT_GR key at all....
Look up the ALT_GR scancode in the Windows documentation, and use it instead of the (right) ALT code. If it really is a library issue, I have no further idea.
@johnwasser
in the windows documentation there is 0xE0 and 0x38 for the ALT-GR Key, but i cant implement it in the keyboard.h, it won't work...
@DrDiettrich
KEY_RIGHT_ALT has on the US keyboard has nothing to do with the german ALT-GR, tried it several times, won't work as the german ALT-GR Key...
and hope that eventual special handling in the library will depend on the name of the key, not on its scancode.
Then use this name in your scripts, where the ALT-GR key is required.
In the worst case you'll have to change many more scancodes in the library, depending on what scancodes are expected by the German keyboard driver in Windows.
Just like on the real keyboard you have to hold the ALT GR key down when pressing the key to be modified. Try that to see if you get the right glyph.
Note that the USB key codes specify a key position, not a glyph. The translations from ASCII to USB key codes in the Arduino library assume a US English QWERTY keyboard. If, for example, you Keyboard.write('y') you will get the the USB key code for the US English keyboard 'y' key. If the OS is configured for a German QWERTZ keyboard it will translate that into a 'z' character. Keep pictures of the two keyboards handy so you can tell which key to use for each character you want.
For values below 128 it looks up the ASCII code and sends the matching US QWERTY keyboard USB key code. The OS configured for a German QWERTZ keyboard will take that USB key code and give you the character that is on that key of the German keyboard. Unfortunately the German QWERTZ keyboard does not have '[' on the same key. In fact the German keyboard doesn't have that character as the unshifted or shifted character on ANY key. To get that character you have to hold down ALT GR to get the THIRD character shown on several keys. This same issue exists for many non-English keyboards because in many languages they use accented characters not normally found on the US keyboard. Since the accented characters are more frequently used than the special characters like @, [, and ] they get pride of place and the special characters are relegated to the ALT GR position.
Thanks, I'm German and know how to use such keyboards
What I don't know is the handling of USB/HID keyboards, in contrast to OS/2 keyboards. The OS/2 style keyboards send scancodes and key press/release messages. This seems to be different with HID keyboards, and I would like to know more about these differences.
If the transmitted codes are virtual (Windows) keycodes, instead of scancodes, then it should be possible to send VK codes immediately, without modifiers. An ALT_GR code is not required for sending characters with ASCII codes - the use of the ALT_GR key is required only for physical keyboards with a German layout.
Just like on the real keyboard you have to hold the ALT GR key down when pressing the key to be modified. Try that to see if you get the right glyph.
Note that the USB key codes specify a key position, not a glyph. The translations from ASCII to USB key codes in the Arduino library assume a US English QWERTY keyboard. If, for example, you Keyboard.write('y') you will get the the USB key code for the US English keyboard 'y' key. If the OS is configured for a German QWERTZ keyboard it will translate that into a 'z' character. Keep pictures of the two keyboards handy so you can tell which key to use for each character you want.
Your solution works, thanks for that mate. My Problem is that i want to send commands via Keyboard.press("This is my Email: test@test.com")
When i use the Keyboard.press function it can't display the @ character, because its not the right definition in the keyboard.cpp file. I need a definition like this:
#define ALTGR 0x86
...
0x14|ALTGR //@
...
is it possible to fix this problem in the keyboard.cpp? I would like to define it there so i can use the Keyboard.press function.
You can do anything in software, but it is non-trivial. The current table uses 7 bits for a keycode and one bit for a Shift flag. To add more shift flags or to access more than the first 128 key codes you will need to expand the lookup table to int. After that you can store whatever you need in the table.
johnwasser:
You can do anything in software, but it is non-trivial. The current table uses 7 bits for a keycode and one bit for a Shift flag. To add more shift flags or to access more than the first 128 key codes you will need to expand the lookup table to int. After that you can store whatever you need in the table.
ok thanks john, i guess i will stay with the easy method.
Thanks all of you for your advice.
This Case isn't perfectly solved by the Keyboard library for foreign keyboardtypes but your method work out for me.
I know i'm kinda late, but you can find a German Keyboard in the Keyboard Arduino lib generator on Github, it use the ALT_GR Key and it work nicely, the file is in the attchement , tested and approved.
So you just have to replace the Keyboard.cpp which is located in :