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

New setting type: key #24

Open
Hans5958 opened this issue Jan 13, 2021 · 3 comments
Open

New setting type: key #24

Hans5958 opened this issue Jan 13, 2021 · 3 comments

Comments

@Hans5958
Copy link
Member

No addon uses it yet, but we'll support settings of type "key". I don't think there's a real way of verifying default key combinations are correct, all I got is the JS code that detects the keys and outputs a string with them. If you wanna go crazy, build a regex for it :P

const string = e.ctrlKey
        ? "Ctrl" +
          (e.shiftKey ? " + Shift" : "") +
          (e.key == "Control" || e.key == "Shift"
            ? ""
            : (e.ctrlKey ? " + " : "") +
              (e.key.toUpperCase() === e.key
                ? e.code.includes("Digit")
                  ? e.code.substring(5, e.code.length)
                  : e.key
                : e.key.toUpperCase()))
        : "";

Originally posted by @WorldLanguages in #13 (comment)

@TheColaber
Copy link
Member

This regex is not to crazy enough... /(\w|[ \+])+/ if the match is equal to the whole string, it pretty much works.

@Hans5958
Copy link
Member Author

This regex is not to crazy enough... /(\w|[ \+])+/ if the match is equal to the whole string, it pretty much works.

Eh, I need at least one example to know whether it works.

@Hans5958 Hans5958 changed the title New "key" property New property: key Feb 28, 2021
@Hans5958
Copy link
Member Author

Hans5958 commented Jul 4, 2021

I did some testing and I finally got this.

/^Ctrl( \+ Shift)?( \+ (.|ALT))?$/

I'll try to create a PR for this later.

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