ScratchAddons icon indicating copy to clipboard operation
ScratchAddons copied to clipboard

Key-pressed blocks: key picker improvements

Open DNin01 opened this issue 1 month ago • 2 comments

Feature request description

The key () pressed? block could be enhanced in multiple ways.

  • [ ] The dropdown menu is a long list, which can make it harder to select a key. Scratch uses unique menus for some blocks like point in direction () and play note () for () seconds. Arranging these items in a real keyboard layout would allow for quicker access.

  • [ ] It could be faster to type in the key you want to select instead of picking it from the menu. editor-searchable-dropdowns already lets you do this, but you still have to click or press Enter on the result.

  • [x] Some keys that can be sensed (e.g., special characters) are not visible in the dropdown menu. The addon editor-extra-keys already adds these as options.

These three improvements would easily fit into one addon that improves the key-selection dropdown menu.

https://github.com/user-attachments/assets/7557e598-d10b-470e-95d0-93b8c4906e65

Related

  • A similar UI could be used for the Gamepad addon (see #7292).

DNin01 avatar Nov 20 '25 20:11 DNin01

Arranging these items in a real keyboard layout would allow for quicker access.

This requires knowing the user's keyboard layout. Unfortunately, the API for that is currently only supported by Chromium: https://developer.mozilla.org/en-US/docs/Web/API/Keyboard/getLayoutMap

mxmou avatar Nov 21 '25 08:11 mxmou

Arranging these items in a real keyboard layout would allow for quicker access.

This requires knowing the user's keyboard layout. Unfortunately, the API for that is currently only supported by Chromium: https://developer.mozilla.org/en-US/docs/Web/API/Keyboard/getLayoutMap

I didn't know about that API! So, we could adapt the displayed keyboard layout on Chrome and fall back to a default of QWERTY on other browsers.

DNin01 avatar Nov 21 '25 16:11 DNin01