Skip to content
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

typeKey(KEY_RETURN); types "(" instead of enter. #419

Open
richardcodingstuff opened this issue Jun 7, 2023 · 1 comment
Open

typeKey(KEY_RETURN); types "(" instead of enter. #419

richardcodingstuff opened this issue Jun 7, 2023 · 1 comment

Comments

@richardcodingstuff
Copy link

I'm using the Duckuino converter and noticed that in my "test" script, the enter key does not work. Instead, it prints "(".

#include <HID-Project.h>
#include <HID-Settings.h>

// Utility function
void typeKey(int key){
Keyboard.press(key);
delay(50);
Keyboard.release(key);
}

void setup()
{
// Start Keyboard and Mouse
AbsoluteMouse.begin();
Keyboard.begin();

// Start Payload
delay(1000);

Keyboard.press(KEY_LEFT_GUI);
Keyboard.press(114);
Keyboard.releaseAll();

delay(200);

Keyboard.print("notepad");

delay(300);

typeKey(KEY_ENTER);

delay(300);

Keyboard.print("guess what?");

delay(5000);

Keyboard.print("you just got....");

Keyboard.print(" _______ ___ _ ______ _____ _");

Keyboard.print("| __ \ \ / / \ | | ____| __ \ | |");

Keyboard.print("| |) \ \ /\ / /| \| | | | | | || |");

Keyboard.print("| ___/ \ \/ \/ / | | __| | | | || |");

Keyboard.print("| | \ /\ / | |\ | |___| |__| |||");

Keyboard.print("|| \/ \/ || \||/ |_|");

// End Payload

// Stop Keyboard and Mouse
Keyboard.end();
AbsoluteMouse.end();
}

// Unused
void loop() {}

@WestonCode
Copy link

This is little old, so not sure if you are still having the same problem.
But hopefully it helps someone like me who just had the same issue.

If you need to move the Keyboard.press() into a utility function like this one.

void typeKey(int key){
    Keyboard.press(key);
    delay(50);
    Keyboard.release(key);
}

You need to pass the key value as a KeyboardKeycode instead of an int or uint8_t
This should work in @richardcodingstuff 's situation.

void typeKey(KeyboardKeycode key){
    Keyboard.press(key);
    delay(50);
    Keyboard.release(key);
}

Basically when you pass the Key code constant as an int to the function, it is effectively the same as calling Keyboard.write(0xB0); instead of Keyboard.write(KEY_RETURN); which it says not to do here: https://github.com/NicoHood/HID/wiki/Keyboard-API#improved-keyboard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants