Skip to content

Add keyboard key style to jspsych.css - #3708

Merged
jodeleeuw merged 11 commits into
mainfrom
feature/keyboard-key-css
Jul 22, 2026
Merged

Add keyboard key style to jspsych.css#3708
jodeleeuw merged 11 commits into
mainfrom
feature/keyboard-key-css

Conversation

@jodeleeuw

@jodeleeuw jodeleeuw commented Jul 21, 2026

Copy link
Copy Markdown
Member

Overview

Adds a CSS style to jspsych.css for rendering text as a keyboard key, so instruction text can mark up key names as visual keycaps using the semantic <kbd> element:

<p>Press <kbd>space</kbd> to continue.</p>

An element with class="key" (e.g. <span class="key">space</span>) is styled identically, as an alternative for cases where <kbd> isn't convenient. The rule is scoped under .jspsych-display-element so it can't leak into a hosting page. The design matches the existing .jspsych-btn palette, with a bottom box-shadow for keycap depth. No capitalization styling is applied — authors control how key names are cased.

Changes

  • packages/jspsych/src/index.scss: new .jspsych-display-element kbd, .jspsych-display-element .key rule (verified the webpack build:styles output picks it up).
  • docs/overview/style.md: short note documenting the style in "Tips for working with CSS".
  • examples/keyboard-key-style.html: minimal demo, <kbd>-first with one class="key" alternative trial.
  • examples/ sweep: 31 example files updated so instruction text naming a specific key uses <kbd> (126 wraps). Generic phrases ("press any key"), code/comments, third-party JS, and button-response labels were left untouched.
  • docs/tutorials/rt-task.md: the F/J key mentions in the tutorial's code samples use <kbd>, kept identical across all repeated code blocks; tutorial prose untouched (the docs site doesn't load jspsych.css).
  • docs/demos/ + docs/plugins/ sweep: 11 demo experiment files updated (23 wraps), plus the 9 plugin doc pages that duplicate those demos' code inline in their "Code" tabs, kept in sync (23 more wraps).
  • Changeset: minor bump for jspsych.

🤖 Generated with Claude Code

jodeleeuw and others added 2 commits July 21, 2026 09:44
Add a `.jspsych-display-element .key` / `kbd` style to jspsych.css so
experiment authors can render text as a keycap in instructions, e.g.
`press <span class="key">space</span>`. Documents the new style in the
CSS overview page and adds a minimal standalone example.

Note: packages/jspsych/css/jspsych.css is a generated build artifact
(gitignored since 60f4d86) and was rebuilt locally to verify the new
rule compiles correctly, but is not committed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Wrap specific key names in <span class="key"> throughout the examples/
demo files so instruction text renders as a keycap using the new
jspsych-display-element .key CSS style. Generic phrasing like "any
key", "a key", "the wrong key", "the other key", and "the correct key"
is left untouched, as are choices arrays, plugin parameters, logic
code, and code comments.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Jul 21, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9c058c5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
jspsych Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@jodeleeuw
jodeleeuw requested a review from jadeddelta July 21, 2026 14:16
@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

📦 Preview build ready

Built from PR head 9c058c5 and published at 218bccb on branch preview/pr-3708.
URLs below are pinned to an immutable commit SHA, so they are safe to share and are cached permanently by jsDelivr.

Changed packages: jspsych

Quick-start HTML:

<script src="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/jspsych/dist/index.browser.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/jspsych/css/jspsych.css">
<script src="https://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-html-keyboard-response/dist/index.browser.min.js"></script>
All package URLs
  • @jspsych/extension-mouse-trackinghttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/extension-mouse-tracking/dist/index.browser.min.js
  • @jspsych/extension-record-videohttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/extension-record-video/dist/index.browser.min.js
  • @jspsych/extension-webgazerhttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/extension-webgazer/dist/index.browser.min.js
  • jspsychhttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/jspsych/dist/index.browser.min.js
  • @jspsych/plugin-animationhttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-animation/dist/index.browser.min.js
  • @jspsych/plugin-audio-button-responsehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-audio-button-response/dist/index.browser.min.js
  • @jspsych/plugin-audio-keyboard-responsehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-audio-keyboard-response/dist/index.browser.min.js
  • @jspsych/plugin-audio-slider-responsehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-audio-slider-response/dist/index.browser.min.js
  • @jspsych/plugin-browser-checkhttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-browser-check/dist/index.browser.min.js
  • @jspsych/plugin-call-functionhttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-call-function/dist/index.browser.min.js
  • @jspsych/plugin-canvas-button-responsehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-canvas-button-response/dist/index.browser.min.js
  • @jspsych/plugin-canvas-keyboard-responsehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-canvas-keyboard-response/dist/index.browser.min.js
  • @jspsych/plugin-canvas-slider-responsehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-canvas-slider-response/dist/index.browser.min.js
  • @jspsych/plugin-categorize-animationhttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-categorize-animation/dist/index.browser.min.js
  • @jspsych/plugin-categorize-htmlhttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-categorize-html/dist/index.browser.min.js
  • @jspsych/plugin-categorize-imagehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-categorize-image/dist/index.browser.min.js
  • @jspsych/plugin-clozehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-cloze/dist/index.browser.min.js
  • @jspsych/plugin-external-htmlhttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-external-html/dist/index.browser.min.js
  • @jspsych/plugin-free-sorthttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-free-sort/dist/index.browser.min.js
  • @jspsych/plugin-fullscreenhttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-fullscreen/dist/index.browser.min.js
  • @jspsych/plugin-html-audio-responsehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-html-audio-response/dist/index.browser.min.js
  • @jspsych/plugin-html-button-responsehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-html-button-response/dist/index.browser.min.js
  • @jspsych/plugin-html-keyboard-responsehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-html-keyboard-response/dist/index.browser.min.js
  • @jspsych/plugin-html-slider-responsehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-html-slider-response/dist/index.browser.min.js
  • @jspsych/plugin-html-video-responsehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-html-video-response/dist/index.browser.min.js
  • @jspsych/plugin-iat-htmlhttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-iat-html/dist/index.browser.min.js
  • @jspsych/plugin-iat-imagehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-iat-image/dist/index.browser.min.js
  • @jspsych/plugin-image-button-responsehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-image-button-response/dist/index.browser.min.js
  • @jspsych/plugin-image-keyboard-responsehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-image-keyboard-response/dist/index.browser.min.js
  • @jspsych/plugin-image-slider-responsehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-image-slider-response/dist/index.browser.min.js
  • @jspsych/plugin-initialize-camerahttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-initialize-camera/dist/index.browser.min.js
  • @jspsych/plugin-initialize-microphonehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-initialize-microphone/dist/index.browser.min.js
  • @jspsych/plugin-instructionshttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-instructions/dist/index.browser.min.js
  • @jspsych/plugin-maxdiffhttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-maxdiff/dist/index.browser.min.js
  • @jspsych/plugin-mirror-camerahttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-mirror-camera/dist/index.browser.min.js
  • @jspsych/plugin-preloadhttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-preload/dist/index.browser.min.js
  • @jspsych/plugin-reconstructionhttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-reconstruction/dist/index.browser.min.js
  • @jspsych/plugin-resizehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-resize/dist/index.browser.min.js
  • @jspsych/plugin-same-different-htmlhttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-same-different-html/dist/index.browser.min.js
  • @jspsych/plugin-same-different-imagehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-same-different-image/dist/index.browser.min.js
  • @jspsych/plugin-serial-reaction-time-mousehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-serial-reaction-time-mouse/dist/index.browser.min.js
  • @jspsych/plugin-serial-reaction-timehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-serial-reaction-time/dist/index.browser.min.js
  • @jspsych/plugin-sketchpadhttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-sketchpad/dist/index.browser.min.js
  • @jspsych/plugin-survey-html-formhttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-survey-html-form/dist/index.browser.min.js
  • @jspsych/plugin-survey-likerthttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-survey-likert/dist/index.browser.min.js
  • @jspsych/plugin-survey-multi-choicehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-survey-multi-choice/dist/index.browser.min.js
  • @jspsych/plugin-survey-multi-selecthttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-survey-multi-select/dist/index.browser.min.js
  • @jspsych/plugin-survey-texthttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-survey-text/dist/index.browser.min.js
  • @jspsych/plugin-surveyhttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-survey/dist/index.browser.min.js
  • @jspsych/plugin-video-button-responsehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-video-button-response/dist/index.browser.min.js
  • @jspsych/plugin-video-keyboard-responsehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-video-keyboard-response/dist/index.browser.min.js
  • @jspsych/plugin-video-slider-responsehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-video-slider-response/dist/index.browser.min.js
  • @jspsych/plugin-virtual-chinresthttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-virtual-chinrest/dist/index.browser.min.js
  • @jspsych/plugin-visual-search-circlehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-visual-search-circle/dist/index.browser.min.js
  • @jspsych/plugin-webgazer-calibratehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-webgazer-calibrate/dist/index.browser.min.js
  • @jspsych/plugin-webgazer-init-camerahttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-webgazer-init-camera/dist/index.browser.min.js
  • @jspsych/plugin-webgazer-validatehttps://cdn.jsdelivr.net/gh/jspsych/jsPsych@218bccb14ff37b8763ae2d0d1aa13a94f1900ef5/packages/plugin-webgazer-validate/dist/index.browser.min.js

Last updated 2026-07-22 15:45 UTC for PR head 9c058c5.

github-actions Bot pushed a commit that referenced this pull request Jul 21, 2026
jodeleeuw and others added 3 commits July 21, 2026 10:19
Wrap specific key names (F, J) in <span class="key"> inside the rt-task
tutorial's experiment code blocks, so the instructions render as keycaps
when readers run the code. Applied identically across all repeated/grown
copies of the code block through the tutorial's steps. Left the tutorial
prose (outside code blocks) and generic phrasing like "press any key"
untouched, since the docs site doesn't load jspsych.css.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Convert the <span class="key"> wraps added in the previous tutorial
commit to <kbd> elements, the semantic HTML tag for keyboard input,
which jspsych.css already styles as a keycap.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Convert the <span class="key"> / <span class='key'> wraps added in the
examples/ sweep (commit 97a602f) to <kbd> elements, the semantic HTML
tag for keyboard input. The CSS already styles both selectors, so
class="key" remains a supported alternative and is left untouched in
the CSS rule.

- examples/*: 126 <span class="key">/<span class='key'> wraps converted
  to <kbd>, removing the quoting concerns from mixed single/double-quoted
  JS strings.
- examples/keyboard-key-style.html: <kbd> is now the primary usage shown,
  with one trial demonstrating that <span class="key"> still works as an
  alternative.
- docs/overview/style.md: leads with <kbd> as the semantic element,
  mentions class="key" as an equivalent alternative.
- .changeset/keyboard-key-css.md: updated wording to lead with <kbd>.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
github-actions Bot pushed a commit that referenced this pull request Jul 21, 2026
jodeleeuw and others added 2 commits July 21, 2026 10:26
Wrap specific key names in <kbd> throughout docs/demos/ experiment
code, so instructions render as keycaps when a reader opens the demo.
Generic phrasing like "any key" and "the wrong/other key" is left
untouched, as are choices arrays, plugin parameters, and third-party
code.

Several plugin doc pages (docs/plugins/*.md) duplicate a demo's code
inline (in addition to iframing the live demo), so those inline code
blocks were updated identically to keep both copies consistent:
audio-keyboard-response.md, canvas-keyboard-response.md,
categorize-animation.md, categorize-html.md, image-keyboard-response.md,
reconstruction.md, same-different-html.md, same-different-image.md,
and visual-search-circle.md.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
github-actions Bot pushed a commit that referenced this pull request Jul 21, 2026
github-actions Bot pushed a commit that referenced this pull request Jul 21, 2026

@jadeddelta jadeddelta left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

worth addressing the one point I gave, but everything else looks spick and span

Comment thread packages/jspsych/src/index.scss Outdated
Rename the .key helper class to .jspsych-key so it follows the
.jspsych-* naming convention used by every other class in the
stylesheet, per review feedback.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
github-actions Bot pushed a commit that referenced this pull request Jul 22, 2026
github-actions Bot pushed a commit that referenced this pull request Jul 22, 2026

@jadeddelta jadeddelta left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

fixed up two things for you, it looks good to go!

@jodeleeuw
jodeleeuw merged commit 9223e94 into main Jul 22, 2026
7 checks passed
@jodeleeuw
jodeleeuw deleted the feature/keyboard-key-css branch July 22, 2026 15:50
@github-actions github-actions Bot mentioned this pull request Jul 22, 2026
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.

2 participants