diff options
Diffstat (limited to 'gatsby-browser.ts')
-rw-r--r-- | gatsby-browser.ts | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/gatsby-browser.ts b/gatsby-browser.ts new file mode 100644 index 0000000..6271f83 --- /dev/null +++ b/gatsby-browser.ts @@ -0,0 +1,36 @@ +import { default as mousetrap } from "mousetrap"; + +declare global { + interface Window { + rick: HTMLIFrameElement | null; + } +} + +export const onInitialClientRender = ( + _: any, + { + sequence = "up up down down left right left right b a", + }: { sequence?: string } = {} +) => { + + mousetrap.bind(sequence, () => { + let iframe = document.createElement("iframe"); + iframe.src = "https://www.youtube.com/embed/dQw4w9WgXcQ?autoplay=1&controls=0"; + iframe.style.position = "fixed"; + iframe.style.top = "0"; + iframe.style.left = "0"; + iframe.style.width = "100%"; + iframe.style.height = "100%"; + iframe.style.border = "none"; + iframe.style.zIndex = "999999"; + document.body.appendChild(iframe); + window.rick = iframe; + }); + + mousetrap.bind("esc", () => { + if (window.rick) { + window.rick.remove(); + window.rick = null; + } + }); +}; |