Momentum-Firmware icon indicating copy to clipboard operation
Momentum-Firmware copied to clipboard

Addition of Numpad Keybindings in js_badusb.c

Open oldip opened this issue 3 months ago • 0 comments

Description of the feature you're suggesting.

I'm suggesting the addition of Numpad keybindings in the js_badusb.c file to enhance the functionality of the firmware. Currently, there are issues with input methods that are not US when using the script. By adding Numpad keybindings, users can utilize combinations like ALT+Numpad to input text, thereby overcoming these issues.

What It Should Do: The suggested modification involves adding the following lines to js_badusb.c:

{"NUMPAD_0", HID_KEYPAD_0},
{"NUMPAD_1", HID_KEYPAD_1},
{"NUMPAD_2", HID_KEYPAD_2},
{"NUMPAD_3", HID_KEYPAD_3},
...

This addition will enable users to employ ALT+Numpad combinations in their scripts, such as the following JavaScript function:

function sendStringViaAltNumpad(str) {
    for (let i = 0; i < str.length; i++) {
        let asciiCode = str.charCodeAt(i);
        badusb.hold("ALT");
        asciiCode.toString().split('').forEach(digit => {
            badusb.press(`NUMPAD_${digit}`);
            delay(10); // Slight delay to ensure keyboard events are processed correctly
        });
        badusb.release("ALT");
        delay(10); // Slight delay to ensure keyboard events are processed correctly
    }
    badusb.press("ENTER"); // Finally, press ENTER key to simulate the behavior of println
}

Note: This feature request aims to extend the existing functionality of the firmware by incorporating Numpad keybindings. It addresses the issue of non-US input methods when using the script, offering users greater flexibility in text input.

Anything else?

As a beginner, I'm unsure about the process of converting the .c format to .fal. Any guidance on this would be appreciated.

Thank you for considering this feature request.

@oldip

oldip avatar Mar 13 '24 17:03 oldip