From 116f44cade1f44b7a579ac1968d84e56aa3c62ce Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Fri, 14 Mar 2025 10:05:14 -0700 Subject: [PATCH] feat: Focus player on page load for immediate keyboard control --- aider/website/_includes/recording.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/aider/website/_includes/recording.js b/aider/website/_includes/recording.js index 499df08a7..fd72738d4 100644 --- a/aider/website/_includes/recording.js +++ b/aider/website/_includes/recording.js @@ -107,6 +107,26 @@ document.addEventListener('DOMContentLoaded', function() { } ); + // Focus on the player element so keyboard shortcuts work immediately + setTimeout(() => { + // Use setTimeout to ensure the player is fully initialized + if (player && typeof player.focus === 'function') { + player.focus(); + } else { + // If player doesn't have a focus method, try to find and focus the terminal element + const playerElement = document.querySelector('.asciinema-terminal'); + if (playerElement) { + playerElement.focus(); + } else { + // Last resort - try to find element with tabindex + const tabbableElement = document.querySelector('[tabindex]'); + if (tabbableElement) { + tabbableElement.focus(); + } + } + } + }, 100); + // Function to display toast notification function showToast(text) { // Get the appropriate container based on fullscreen state