Skip to content

Add keyboardcontrols=1 flag to enable testing "on by default"#11185

Merged
riknoll merged 3 commits intomicrosoft:masterfrom
microbit-matt-hillsdon:flag-keyboardcontrols-1
Mar 12, 2026
Merged

Add keyboardcontrols=1 flag to enable testing "on by default"#11185
riknoll merged 3 commits intomicrosoft:masterfrom
microbit-matt-hillsdon:flag-keyboardcontrols-1

Conversation

@microbit-matt-hillsdon
Copy link
Copy Markdown
Contributor

@microbit-matt-hillsdon microbit-matt-hillsdon commented Mar 10, 2026

This is a temporary flag to enable trialing enabling keyboard controls by default. Micro:bit Educational Foundation are going to do that in their tools that embed MakeCode and provide feedback. This might then be a route to simply enabling them in the next release.

I've implemented this by flipping the default based on the flag.

Now that the user isn't naturally exposed to the help by enabling keyboard controls, we show the same help toast as Blockly when the workspace is focused from the skip link. It might be nice to do this in other scenarios (e.g. first tab to the workspace) but that is a riskier change.

There are still some arguable downsides from this flag that we might want to address before making it the default:

  • It enables "passive focus" dashed outline around blocks. The purpose of this is to remind the user of the workspace context (which is where e.g. a toolbox block insert will be relative to). But this is more relevant to keyboard users. Passive focus is enabled based on Blocky's logic about whether keyboard navigation has been used which can be a bit hard to predict as a user.

  • The active area indicator for the workspace (black focus ring) is also shown for all users. When a user clicks on the workspace background we also indicate that the workspace itself has focus via the yellow ring (as per blocks). We have in the past proposed making this conditional on keyboard navigation being in use (so it feels like focus-visible CSS).

Both intentionally unaddressed for now so we can:

  1. reduce risk of this change, which is needed in live MakeCode
  2. gather feedback specifically from folks who notice these changes

Another aspect we intend to monitor is feedback from folks who might unintentionally trigger shortcuts.

For telemetry I've intentionally not triggered an event from the default setting and I've tagged the event source for subsequent changes with the fact it was on by default. Please consider this part carefully, I don't have enough info to make a good proposal.

Impact on existing users:

  1. In the iframe case we only ever persisted the settings to the individual local storage keys when the user changed them, so the flag can change the default for existing users.
  2. In the non-iframe/auth case, the defaults (previously false) were proactively persisted so we cannot tell the difference between a user's choice to turn off keyboard controls and the default state, so we respect the persisted setting. This isn't significant for the testing we plan as we'll be using the iframe case.

Warning: if you test this locally note settings are in .pxt/storage on disk not browser storage.

Fixes microsoft/pxt-microbit#6704

This is a temporary flag to enable trialing enabling keyboard controls by
default. Micro:bit Educational Foundation are going to do that in their tools
that embed MakeCode and provide feedback. This might then be a route to simply
enabling them in the next release.

I've implemented this by flipping the default based on the flag.

Now that the user isn't naturally exposed to the help by enabling keyboard
controls, we show the same help toast as Blockly when the workspace is focused
from the skip link. It might be nice to do this in other scenarios (e.g. first
tab to the workspace) but that is a riskier change.

There are still some arguable downsides from this flag that we might want to
address before making it the default:

- It enables "passive focus" dashed outline around blocks. The purpose of this
  is to remind the user of the workspace context (which is where e.g. a toolbox
  block insert will be relative to). But this is more relevant to keyboard
  users. Passive focus is enabled based on Blocky's logic about whether
  keyboard navigation has been used which can be a bit hard to predict as a
  user.

- The active area indicator for the workspace (black focus ring) is also shown
  for all users. When a user clicks on the workspace background we also
  indicate that the workspace itself has focus via the yellow ring (as per
  blocks). We have in the past proposed making this conditional on
  keyboard navigation being in use (so it feels like focus-visible CSS).

Both intentionally unaddressed for now so we can:

1. reduce risk of this change, which is needed in live MakeCode
2. gather feedback specifically from folks who notice these changes

Another aspect we intend to monitor is feedback from folks who might
unintentionally trigger shortcuts.

For telemetry I've intentionally not triggered an event from the default
setting and I've tagged the event source for subsequent changes with the fact
it was on by default.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a temporary keyboardcontrols=1 URL flag to flip the default for Blocks keyboard controls (accessible blocks), enabling “on by default” trials for embedded MakeCode scenarios and tagging subsequent telemetry sources accordingly. It also adds a one-time help toast when the Blocks workspace is focused via the accessibility “skip link” path to compensate for users no longer seeing enablement guidance.

Changes:

  • Added core.isKeyboardControlsByDefault() to detect keyboardcontrols=1 and use it to default accessible blocks when no persisted preference exists.
  • Added a pending “keyboard controls help” hint flow that shows a Blockly toast when the workspace is focused after using the accessibility menu’s “Skip to Blocks workspace”.
  • Updated user preference defaulting and typings to support flag-based default behavior and telemetry source tagging.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
webapp/src/core.ts Adds flag detection helper for keyboard controls defaulting.
webapp/src/blocks.tsx Adds pending hint state + help toast shown on workspace focus.
webapp/src/auth.ts Defaults accessible blocks to the flag value when no stored/cloud pref exists.
webapp/src/app.tsx Plumbs optional hint parameter through openBlocks() and tags telemetry sources when flag is active.
webapp/src/accessibility.tsx Triggers the hint behavior when using the accessibility menu to focus the Blocks workspace.
pxtlib/auth.ts Changes default user preferences to avoid proactively setting a fixed accessible-blocks default.
localtypings/pxteditor.d.ts Updates openBlocks() signature to accept an optional hint flag.

Comment thread webapp/src/core.ts
Comment thread webapp/src/blocks.tsx Outdated

showKeyboardControlsHint() {
if (!this.editor || !Blockly.Msg["HELP_PROMPT"]) return;
const isMac = navigator.platform.startsWith("Mac");
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

showKeyboardControlsHint() detects macOS via navigator.platform.startsWith("Mac"). The codebase already uses pxt.BrowserUtils.isMac() for this (e.g. webapp/src/components/KeyboardControlsHelp.tsx), and navigator.platform is increasingly unreliable/deprecated across browsers. Using the shared helper will keep platform detection consistent (and avoid iPadOS edge cases).

Suggested change
const isMac = navigator.platform.startsWith("Mac");
const isMac = pxt.BrowserUtils.isMac();

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@riknoll
Copy link
Copy Markdown
Member

riknoll commented Mar 11, 2026

@abchatra care to weigh in on the telemetry changes? i wonder if it would be better to just add the "on by default" as a custom dimension rather than changing the event name itself

@abchatra
Copy link
Copy Markdown
Collaborator

Yes, custom dimension would be good.

- use defaultOn as a telemetry dimension
- use BrowserUtils.isMac()
@microbit-matt-hillsdon
Copy link
Copy Markdown
Contributor Author

Yes, custom dimension would be good.

Makes sense, switched to custom dimension "defaultOn" with true/false values in f9239cb.

@riknoll riknoll enabled auto-merge (squash) March 12, 2026 17:17
@riknoll riknoll merged commit 1711b1a into microsoft:master Mar 12, 2026
12 checks passed
@microbit-matt-hillsdon
Copy link
Copy Markdown
Contributor Author

So we can test in CreateAI, please can you cherry-pick this to the relevant pxt, bump stable pxt-microbit's version and release to live? Thanks.

@abchatra
Copy link
Copy Markdown
Collaborator

abchatra commented Mar 13, 2026

Can you test createAI in /beta first and ensure everything works before we port?

@microbit-matt-hillsdon
Copy link
Copy Markdown
Contributor Author

Can you test createAI in /beta first and ensure everything works before we port?

Yes, but I think beta isn't sufficiently up-to-date to do that testing.

beta has pxt 12.3.2 which doesn't have this PR yet.

If you can tag a pxt release and update beta (or point me to another deployment to test against) then I can test with CreateAI. Thanks.

@abchatra
Copy link
Copy Markdown
Collaborator

@microbit-matt-hillsdon I have bumped microbit, please validate when the build is out.

@microbit-matt-hillsdon
Copy link
Copy Markdown
Contributor Author

@microbit-matt-hillsdon I have bumped microbit, please validate when the build is out.

Thanks @abchatra, I can confirm this is working for us when I test with CreateAI + beta + flag enabled.

@abchatra
Copy link
Copy Markdown
Collaborator

@microbit-matt-hillsdon can you port only the required changes to stable12.0 branch and produce a PR? https://github.com/microsoft/pxt/tree/stable12.0

I will take it from there.

microbit-matt-hillsdon added a commit to microbit-matt-hillsdon/pxt that referenced this pull request Mar 18, 2026
This should have been part of microsoft#11185 to fully address the feedback (I added the
dimension but didn't remove this alternative approach).
riknoll added a commit that referenced this pull request Mar 19, 2026
)

This should have been part of #11185 to fully address the feedback (I added the
dimension but didn't remove this alternative approach).

Co-authored-by: Richard Knoll <riknoll@users.noreply.github.com>
microbit-matt-hillsdon added a commit to microbit-matt-hillsdon/pxt that referenced this pull request Mar 20, 2026
…oft#11185)

* Add keyboardcontrols=1 flag to enable testing "on by default"

This is a temporary flag to enable trialing enabling keyboard controls by
default. Micro:bit Educational Foundation are going to do that in their tools
that embed MakeCode and provide feedback. This might then be a route to simply
enabling them in the next release.

I've implemented this by flipping the default based on the flag.

Now that the user isn't naturally exposed to the help by enabling keyboard
controls, we show the same help toast as Blockly when the workspace is focused
from the skip link. It might be nice to do this in other scenarios (e.g. first
tab to the workspace) but that is a riskier change.

There are still some arguable downsides from this flag that we might want to
address before making it the default:

- It enables "passive focus" dashed outline around blocks. The purpose of this
  is to remind the user of the workspace context (which is where e.g. a toolbox
  block insert will be relative to). But this is more relevant to keyboard
  users. Passive focus is enabled based on Blocky's logic about whether
  keyboard navigation has been used which can be a bit hard to predict as a
  user.

- The active area indicator for the workspace (black focus ring) is also shown
  for all users. When a user clicks on the workspace background we also
  indicate that the workspace itself has focus via the yellow ring (as per
  blocks). We have in the past proposed making this conditional on
  keyboard navigation being in use (so it feels like focus-visible CSS).

Both intentionally unaddressed for now so we can:

1. reduce risk of this change, which is needed in live MakeCode
2. gather feedback specifically from folks who notice these changes

Another aspect we intend to monitor is feedback from folks who might
unintentionally trigger shortcuts.

For telemetry I've intentionally not triggered an event from the default
setting and I've tagged the event source for subsequent changes with the fact
it was on by default.

* keyboardcontrols=1 flag tweaks based on PR feedback:

- use defaultOn as a telemetry dimension
- use BrowserUtils.isMac()

---------

Co-authored-by: Richard Knoll <riknoll@users.noreply.github.com>
microbit-matt-hillsdon added a commit to microbit-matt-hillsdon/pxt that referenced this pull request Mar 20, 2026
…rosoft#11198)

This should have been part of microsoft#11185 to fully address the feedback (I added the
dimension but didn't remove this alternative approach).

Co-authored-by: Richard Knoll <riknoll@users.noreply.github.com>
@microbit-matt-hillsdon
Copy link
Copy Markdown
Contributor Author

@microbit-matt-hillsdon can you port only the required changes to stable12.0 branch and produce a PR? https://github.com/microsoft/pxt/tree/stable12.0

I will take it from there.

Thanks, see #11206

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.

Support a flag to enable testing keyboard controls on by default via iframe

4 participants