diff --git a/packages/react/src/components/MiniRepl.jsx b/packages/react/src/components/MiniRepl.jsx index 508353e4..27d17983 100644 --- a/packages/react/src/components/MiniRepl.jsx +++ b/packages/react/src/components/MiniRepl.jsx @@ -11,6 +11,7 @@ import styles from './MiniRepl.module.css'; import './style.css'; import { logger } from '@strudel.cycles/core'; import useEvent from '../hooks/useEvent.mjs'; +import useKeydown from '../hooks/useKeydown.mjs'; const getTime = () => getAudioContext().currentTime; @@ -74,6 +75,27 @@ export function MiniRepl({ color: highlightColor, }); + // keyboard shortcuts + useKeydown( + useCallback( + async (e) => { + if (view?.hasFocus) { + if (e.ctrlKey || e.altKey) { + if (e.code === 'Enter') { + e.preventDefault(); + flash(view); + await activateCode(); + } else if (e.code === 'Period') { + stop(); + e.preventDefault(); + } + } + } + }, + [activateCode, stop, view], + ), + ); + // set active pattern on ctrl+enter useLayoutEffect(() => { if (enableKeyboard) { diff --git a/website/astro.config.mjs b/website/astro.config.mjs index d4ef2735..f8f345b8 100644 --- a/website/astro.config.mjs +++ b/website/astro.config.mjs @@ -41,6 +41,7 @@ export default defineConfig({ [ /^https:\/\/raw\.githubusercontent\.com\/.*/i, /^https:\/\/freesound\.org\/.*/i, + /^https:\/\/cdn\.freesound\.org\/.*/i, /^https:\/\/shabda\.ndre\.gr\/.*/i, ].some((regex) => regex.test(url)), handler: 'CacheFirst',