Skip to content

Conversation

@gonfunko
Copy link
Contributor

This PR fixes #534 by registering a keyboard shortcut under the key combos of all existing keyboard shortcuts that commits the in-progress move before returning control to the corresponding real keyboard shortcut. To fully function, this depends on RaspberryPiFoundation/blockly#9109; without it, moves will be commited, but the underlying/real shortcut action may not run.

@gonfunko gonfunko requested a review from a team as a code owner May 29, 2025 16:57
@gonfunko gonfunko requested review from rachel-fenichel and removed request for a team May 29, 2025 16:57
Copy link
Collaborator

@rachel-fenichel rachel-fenichel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add this test:

  • start a move with keys
  • press an arrow key twice
  • press c
  • press an arrow key twice
  • check that the block is in the expected location

utils.KeyCodes.LEFT,
utils.KeyCodes.UP,
utils.KeyCodes.DOWN,
utils.KeyCodes.ENTER,
Copy link
Contributor

@microbit-matt-hillsdon microbit-matt-hillsdon May 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also needs KeyCodes.SPACE from the finish move action alongside ENTER.

Potentially these could be pulled from a list of the move actions from move.ts? Would be helpful in future as we hope to add UI with the ability to rebind shortcuts (though these ones are perhaps less likely to change than some).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And we do anticipate that when all of the keyboard nav code makes it into core, the shortcut actions will directly cancel moves. This setup is necessary because some shortcuts are in core and some are in the plugin. We will keep UI rebinding in mind for design work on that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't actually need space, because this shortcut finishes the move itself; Enter is there to support command-enter to bring up the contextual menu, not to commit the move. But we do need Escape to abort the move, so I added that in (and cleaned up this shortcut in the new common cleanup method introduced in #561).

@microbit-matt-hillsdon
Copy link
Contributor

Would be great to get #561 in first and clean up this new shortcut in the new common clean-up method, as presumably it should be cleaned up on abort too. Or call in both places here and I can fix conflicts with the other PR.

Copy link
Collaborator

@rachel-fenichel rachel-fenichel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, and I'm okay with merging as-is since this is a blocker.

And a tag for RaspberryPiFoundation/blockly#8915 in case you don't get to writing that test today.

@gonfunko gonfunko merged commit 306d4fc into main May 29, 2025
8 checks passed
@gonfunko gonfunko deleted the move-shortcuts branch May 29, 2025 20:01
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

Successfully merging this pull request may close these issues.

Confirm / finish keyboard moves on subsequent actions

4 participants