{"id":22345655,"url":"https://github.com/gerhynes/key-sequence-detection","last_synced_at":"2025-06-26T02:35:29.289Z","repository":{"id":106045660,"uuid":"106324935","full_name":"gerhynes/key-sequence-detection","owner":"gerhynes","description":"A page made to practice working with key sequence detection. Built for Wes Bos' JavaScript 30 course. ","archived":false,"fork":false,"pushed_at":"2018-01-14T19:31:27.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-12T22:36:36.319Z","etag":null,"topics":["javascript","javascript30"],"latest_commit_sha":null,"homepage":"https://gk-hynes.github.io/key-sequence-detection/","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gerhynes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-09T19:13:20.000Z","updated_at":"2018-01-23T21:49:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"36673470-19fe-431c-a7a9-f67651e00c9b","html_url":"https://github.com/gerhynes/key-sequence-detection","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gerhynes/key-sequence-detection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gerhynes%2Fkey-sequence-detection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gerhynes%2Fkey-sequence-detection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gerhynes%2Fkey-sequence-detection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gerhynes%2Fkey-sequence-detection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gerhynes","download_url":"https://codeload.github.com/gerhynes/key-sequence-detection/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gerhynes%2Fkey-sequence-detection/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261987453,"owners_count":23240843,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","javascript30"],"created_at":"2024-12-04T09:18:21.227Z","updated_at":"2025-06-26T02:35:29.228Z","avatar_url":"https://github.com/gerhynes.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [Key Sequence Detection](https://gk-hynes.github.io/key-sequence-detection/)\n\nA page made to practice working with key sequence detection, in this case the Konami code. Built for Wes Bos' [JavaScript 30](https://javascript30.com/) course.\n\n[![Screenshot of key sequence detection page, with Konami logo](https://res.cloudinary.com/gerhynes/image/upload/v1515946849/Screenshot-2018-1-14_Key_Detection_2_hfubj8.png)](https://gk-hynes.github.io/key-sequence-detection/)\n\n## Notes\n\nCreate an empty array, `pressed`.\nCreate a secret code, here the Konami code.\n\nListen for the keyup event on the window. Log `e.key` to record the key that was pressed.\n\nWhenever someone presses a key push its value into the `pressed` array.\n\nSplice the array elements, starting from the end, and only take the amount needed to trigger the secret code.\n\n```js\npressed.splice(-secretCode.length, pressed.length - secretCode.length);\n```\n\nTurn the array into a string and check if it includes the secret code.\n\nAt this stage run something fun, for example cornify.js to add unicorns and rainbows.\n\n```js\nif (pressed.join(\"\").includes(secretCode)) {\n  console.log(\"DING DING!\");\n  cornify_add();\n}\n```\n\n### Personal refactor\n\nSince cornify.js does not use https you may run into problems.\n\nOne alternative is to show a gif when the secret code is entered.\n\nHere the logo, keycode and (initially hidden) gif are selected. Then a function, `replaceLogo`, is run. This function adds classes of hidden to the standard logo and keycode and active to the secret gif, which sets the standard logo and keycode to `display: none;` and the secret gif to `display: block;`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgerhynes%2Fkey-sequence-detection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgerhynes%2Fkey-sequence-detection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgerhynes%2Fkey-sequence-detection/lists"}