From 4f4b10fd868680e0b87511d4bcf755f198089e8d Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Fri, 14 Mar 2025 19:43:16 -0700 Subject: [PATCH] feat: Hide keyboard shortcuts on devices without physical keyboards --- aider/website/_includes/recording.css | 5 +++++ aider/website/_includes/recording.js | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/aider/website/_includes/recording.css b/aider/website/_includes/recording.css index 34f965960..803e293e6 100644 --- a/aider/website/_includes/recording.css +++ b/aider/website/_includes/recording.css @@ -138,6 +138,11 @@ li.active-marker { margin-bottom: 20px; } +/* Hide keyboard shortcuts on devices likely without physical keyboards */ +.no-physical-keyboard .keyboard-shortcuts { + display: none; +} + .keyboard-shortcuts kbd { background-color: #f7f7f7; border: 1px solid #ccc; diff --git a/aider/website/_includes/recording.js b/aider/website/_includes/recording.js index 17cbfb2f7..85ffcf0c5 100644 --- a/aider/website/_includes/recording.js +++ b/aider/website/_includes/recording.js @@ -2,6 +2,25 @@ document.addEventListener('DOMContentLoaded', function() { let player; // Store player reference to make it accessible to click handlers let globalAudio; // Global audio element to be reused + // Detect if device likely has no physical keyboard + function detectNoKeyboard() { + // Check if it's a touch device (most mobile devices) + const isTouchDevice = ('ontouchstart' in window) || + (navigator.maxTouchPoints > 0) || + (navigator.msMaxTouchPoints > 0); + + // Check common mobile user agents as additional signal + const isMobileUA = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); + + // If it's a touch device and has a mobile user agent, likely has no physical keyboard + if (isTouchDevice && isMobileUA) { + document.body.classList.add('no-physical-keyboard'); + } + } + + // Run detection + detectNoKeyboard(); + // Parse the transcript section to create markers and convert timestamps to links function parseTranscript() { const markers = [];