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

Web specifications for analog keyboards #229

Open
rektide opened this issue Jul 2, 2023 · 2 comments
Open

Web specifications for analog keyboards #229

rektide opened this issue Jul 2, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@rektide
Copy link

rektide commented Jul 2, 2023

Is your feature request related to a problem? Please describe.

I'm a webdev, and would love to make use of the excellent & interesting keyboards Wooting has. Currently, to my knowledge, there's no way to make use of the truly excellent analog keyboards Wooting makes on the world wide web. I see that as a problem for the web, that should be addressed.

Describe the solution you'd like

I'd love a Web standard to recognize & support analog keyboard key presses. This would make the whole wide world better.

Describe alternatives or workarounds you've considered

Giving up? Doing nothing?

Additional context

I've tried to start some dialog by opening an issue for a web specification. I picked the w3c/gamepad specification as a starting point because they are so intimate with how to represent continuous time analog signals. That issue is w3c/gamepad#187.

Input Events specification is another obvious place to start dialog, see what might be possible.

Additional information

Platform information

The web. Chrome, Firefox, whatever.

@rektide rektide added the enhancement New feature or request label Jul 2, 2023
@nondebug
Copy link

nondebug commented Jul 5, 2023

I maintain the Gamepad API specification and the Chromium implementation. I don't see a way we can support pressure-sensitive keyboards in Gamepad API due to the potential for keystroke logging.

I also maintain WebHID API which may be relevant. Pressure-sensitive keyboards might work with WebHID or might not, depending on how the HID report descriptor is structured. WebHID blocks access to top-level collections with the "Generic Desktop Keyboard" usage, so standard keyboard functionality is not accessible but vendor-defined functionality may be accessible if it's defined in a separate top-level collection with a different usage ID. That said, if the vendor-defined functionality contains keystroke data then we would probably want to add the device to the HID blocklist. If you can provide HID report descriptors for a pressure-sensitive keyboard I'm happy to take a look.

@Sainan
Copy link
Contributor

Sainan commented Nov 3, 2023

There is no universal analogue keyboard interface, but in regards to Wooting it is possible to read the analogue input reports via WebHID:

<button>Press me for the mandatory user gesture</button>
<script>
document.querySelector("button").onclick = function()
{
    navigator.hid.requestDevice({ filters: [
        {
            usagePage: 0xff54
        }
    ] }).then(device => {
        console.log(device[0].productName + " selected");
        device[0].open().then(() => {
            console.log(device[0].productName + " connected");
            device[0].addEventListener("inputreport", event => {
                let scancode = event.data.getUint16(0);
                let value = event.data.getUint8(2);
                console.log("Pressure on " + scancode + ": " + (value / 255));
            });
        })
    });
};
</script>

Mind that this is a very shitty way of doing it because the input reports allow for anywhere from 0 to 16 keys to be reported.

There are also Razer analogue keyboards which simply use report id 7 — you might not be able to get those via WebHID, tho.

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

No branches or pull requests

3 participants