Skip to content

Instantly share code, notes, and snippets.

View WestonThayer's full-sized avatar

Weston Thayer WestonThayer

View GitHub Profile
// https://github.com/microsoft/playwright/issues/27130
/**
* Turn a single string character into KeyboardEvent.code and whether a Shift
* modifier is required.
*
* I have no idea how this works if your local keyboard layout isn't US.
*
* @param {string} char
*
name: test
on:
push:
branches: [main]
jobs:
test:
runs-on: windows-latest
steps:
- run: "& 'C:\\Windows\\Resources\\Ease of Access Themes\\hc1.theme'"
# Will upload an artifact to the run with a desktop screenshot
<button aria-pressed="false">
<span aria-hidden>13</span>
<span class="visually-hidden">
13 December
</span>
</button>
<!-- Read as "13 13 December" -->

x-height test while zooming

A basic algorithm to check if any given webpage has "accessible" text scaling, based on w3c/silver#506 (comment), which approximates x-height as ~50% of font-size (so the min and max x-height sizes from user research have been 2x'd):

  • All text can reach a rendered font-size of least ~88 CSS px
  • No text exceeds a rendered font-size of ~120 CSS px

By "rendered font-size", I mean the computed CSS font-size value multiplied by the current zoom level (100%, 150%, etc). So for example, assuming linear scaling, 17.6px would be the minimum acceptable size because browsers have a max zoom of 500% and 17.6 * 5 = 88.

  1. Start at some "desktop" viewport, say 1280px wide, and 100% zoom
@WestonThayer
WestonThayer / android-in-cloud-for-talkback.md
Last active September 9, 2021 19:09
Notes on running Android emulators in the cloud for testing TalkBack

Twitter thread for context: https://twitter.com/__grunet/status/1434197313795330049

Q: Is it possible to run the Android Emulator in the cloud?

A: Yes, either in a bare metal cloud or with nested virtualization.

Q: Is it easy to set up?

A: Sort of, I'm sure a lot of it could be scripted. https://github.com/budtmo/docker-android has put a lot of work into making it fast once you have a Linux machine ready (I didn't test it). With nested virtualization, you could do these steps once and take a VM image.

@WestonThayer
WestonThayer / _app.jsx
Last active March 14, 2022 21:06
Basic Next.js focus restoration
// Browsers keep track of where your keyboard focus is when you click
// a link, and they restore focus to the same link when you navigate
// back (via https://web.dev/bfcache/)
//
// SPAs like Next.js break this paradigm because they handle routing
// themselves. This is a basic approach bringing the feature back. It
// doesn't handle restoring the view-state (well, Next.js handles
// scroll restoration out-of-the-box, but that's it) like re-opening
// dropdowns or dialogs or FAQ items that contained the clicked link.
(*
VoiceOver Translator
Version: 1.1
Copyright 2020 Tyflos Accessible Software. All rights reserved.
You may incorporate this Tyflos Accessible Software sample code into your system and program(s) without restriction.
This sample code has been provided "AS IS" and the responsibility for its operation is yours.
You are not permitted to redistribute this Tyflos Accessible Software sample code as "Tyflos Accessible Software sample code" after having made changes. If you're going to redistribute the code, we require that you make it clear that the code was descended from Tyflos Accessible Software sample code, but that you've made changes.
@WestonThayer
WestonThayer / typing.applescript
Created December 14, 2020 19:49
MacOS Automator AppleScript for typing
# Using MacOS Automator to type in any application. Useful for
# apps that don't support pasting
#
# To configure:
#
# 1. Open Automator
# 2. Create a new Quick Action (formerly known as a Service)
# 3. Workflow receives: no input
# 4. in: any application (you may need to grant Automator Accessibility
# access in System Preferences)
// All tests visiting a page with this HTML:
//
// <p>content before</p>
//
// <ol id="target">
// <li>
// Cats
// <ol>
// <li>Big cat</li>
// <li>Small cat</li>
@WestonThayer
WestonThayer / instructions.md
Created August 9, 2019 01:01
App to get Windows scancodes

How to compile

On a Windows machine, you'll first need Visual Studio (the free version is fine). Once that's complete:

  1. Open a command prompt
  2. Find vcvarsall.bat in your VS installation path, then call it with x64 as it's argument. It will look something like: call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" x64
  3. Run cl main.c -nologo -Zi -link user32.lib

That should compile and generate main.exe.