mirror of
https://github.com/maikka39/Personal-Website.git
synced 2026-10-02 14:46:25 +00:00
Add terminal like cd functionality
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
window.addEventListener("load", () => {
|
||||
const terminal = document.getElementById('nav-terminal')
|
||||
|
||||
const keyDown = (e) => {
|
||||
if (e.keyCode === 13) {
|
||||
if (document.activeElement !== document.body) return
|
||||
if (terminal.textContent.length === 0) return
|
||||
|
||||
if (terminal.textContent.includes("~")) terminal.textContent = ""
|
||||
|
||||
window.location.href = window.location.origin + "/" + terminal.textContent
|
||||
return
|
||||
}
|
||||
|
||||
if (e.keyCode === 8) {
|
||||
terminal.textContent = terminal.textContent.slice(0, -1)
|
||||
return
|
||||
}
|
||||
|
||||
if (e.keyCode === 192) {
|
||||
if (terminal.textContent.length !== 0) return
|
||||
|
||||
terminal.textContent += "~"
|
||||
return
|
||||
}
|
||||
|
||||
if ((e.keyCode < 65 || e.keyCode > 90) && (e.keyCode !== 191) ) return
|
||||
|
||||
terminal.textContent += e.key.toLowerCase()
|
||||
}
|
||||
|
||||
document.addEventListener('keydown', keyDown)
|
||||
})
|
||||
@@ -23,7 +23,7 @@
|
||||
width: 10px;
|
||||
height: 1rem;
|
||||
background: #252627;
|
||||
margin-left: 5px;
|
||||
margin-left: 2px;
|
||||
border-radius: 1px;
|
||||
animation: cursor 1s infinite;
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// // Fading
|
||||
@@ -68,4 +67,4 @@
|
||||
100% {
|
||||
visibility: visible;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user