diff --git a/content/console.md b/content/console.md new file mode 100644 index 0000000..262408e --- /dev/null +++ b/content/console.md @@ -0,0 +1,4 @@ ++++ +title = "Console" +template = "console.html" ++++ diff --git a/sass/console.scss b/sass/console.scss new file mode 100644 index 0000000..38c3a00 --- /dev/null +++ b/sass/console.scss @@ -0,0 +1,5 @@ +.console { + background: gray; + width: 80vw; + min-height: 20vh; +} diff --git a/static/js/console.js b/static/js/console.js new file mode 100644 index 0000000..87f71b7 --- /dev/null +++ b/static/js/console.js @@ -0,0 +1,43 @@ +const c = document.querySelector(".console") +const ps1 = "[fr@website ~]$ " + +function write(key) { + console.log("KEY:", key) + switch(key) { + case "Enter": + c.innerHTML += "
" + c.innerHTML += ps1 + return + case "000ctrll": + c.innerHTML = "" + c.innerHTML += ps1 + return + default: + c.innerHTML += key + } +} + +function customCtrlShortcuts(plusKey) { + document.addEventListener("keydown", e => { + if(e.ctrlKey && e.key == plusKey) { + e.preventDefault() + write("000ctrl"+plusKey) + } + }) +} + +// On load init the terminal +window.addEventListener("load", () => { + write("000ctrll") +}) + +// Capture the keypress +window.addEventListener("keypress", e => { + console.log(e) + write(e.key) +}) + +// Register custom ctrl shortcuts +customCtrlShortcuts("l") // ctrl + l +customCtrlShortcuts("c") // ctrl + c + diff --git a/templates/console.html b/templates/console.html new file mode 100644 index 0000000..9337d4c --- /dev/null +++ b/templates/console.html @@ -0,0 +1,11 @@ +{% extends "base.html" %} + +{% block styles %} + +{% endblock styles %} + +{% block content %} +
+
+ +{% endblock content %}