Allow "e" keyboard shortcut to edit a post

This commit is contained in:
Gabriel Augendre 2020-11-24 18:28:47 +01:00
parent 2849692fc1
commit b99e63dbcd
No known key found for this signature in database
GPG key ID: 1E693F4CE4AEE7B4
2 changed files with 14 additions and 1 deletions

View file

@ -17,3 +17,16 @@ function darkModeListener(e) {
let mql = window.matchMedia("(prefers-color-scheme: dark)");
darkModeListener(mql);
mql.addListener(darkModeListener);
window.onload = function () {
const adminLinkElement = document.querySelector(".article-detail .metadata a.admin-link");
if (adminLinkElement === undefined || adminLinkElement === null) {
return;
}
const adminLocation = adminLinkElement.href;
document.addEventListener("keydown", event => {
if (event.code === "KeyE") {
window.location = adminLocation;
}
})
}

View file

@ -8,7 +8,7 @@
<link rel="stylesheet" id="code-light" href="{% static 'code-light.css' %}" type="text/css">
<link rel="stylesheet" id="code-dark" href="{% static 'code-dark.css' %}" type="text/css">
<link rel="stylesheet" href="{% static 'style.css' %}" type="text/css">
<script src="{% static 'toggle-dark-mode.js' %}" async></script>
<script src="{% static 'scripts.js' %}" async></script>
<link rel="alternate" type="application/rss+xml" title="Gab's Notes » Feed" href="{% url 'complete-feed' %}">
{% include "articles/favicon.html" %}
{% include "articles/analytics.html" %}