Can You Capture Keyboard [ or ]

I have a slider which controls the brush size which works fine.

Question:
I would like the slider on the plugin to change value if the [ or ] is used on the keyboard.

Is this possible ?

Only if your plugin has focus can you intercept these shortcuts. But I’d be really careful about co-opting these, given that it may not be obvious to a user that your plugin is taking those shortcuts over.

Example:

document.getElementById("testSlider").addEventListener("keydown", evt => {
    if (evt.key==="[") { evt.target.value--; }
    if (evt.key==="]") { evt.target.value++; }
});

The above will only work if the slider already has focus. By default mouse clicks will not give focus here. You can force focus by calling focus and then the brackets would start working.

Where and how would you call focus Kerri

Note: on my Czech keyboard these keys are not present. Also Photoshop has similar shortcuts hardcoded and are impossible to use for Czechs with default keyboard.

2 Likes

What keys do you use to increase/decrease the brush size

Alt + right click down + drag

This is such a useful bit of information that I’d never considered as a QWERTY native.

based on what @Jarda has said I think it could be dangerous to try and hook in the keyboard shortcuts then. I just assumed the was standard thoughout

Anyone who has a localised keyboard (mine is Italian) and uses Photoshop in English is bound to suffer.

Fun fact: I switched to using the US (QWERTY) keyboard layout (instead of my natively learned German QWERTZ) because it’s much “smoother” to use for most of my use-cases because so many apps don’t consider other keyboard layouts.

  • when writing in LaTeX, the backslash \ (which would be Alt Gr+ß in German QWERTZ – ß is equivalent to QWERTY -) is much easier to use
  • all kinds of programming symbols ({}[]<>|'";) are much more accessible in QWERTY
  • keyboard shortcuts in IDEs and other software … work :sweat_smile:
1 Like

Yes but in German you don’t use ěščřžýáíéťďňúů on regular basis :smiley: Just üöäß I got myself


…and assigned “G” keys around spacebar to most used programming characters. :smiley:

Alternatively Microsoft provides tool to create custom layout. https://www.microsoft.com/en-us/download/details.aspx?id=102134

1 Like