Skip to content

Loading…

sandbox: add ctrl+enter support to trigger render() #5

Merged
merged 4 commits into from

2 participants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Showing with 16 additions and 0 deletions.
  1. +8 −0 sandbox/index.html
  2. +8 −0 sandbox/sandbox.js
View
8 sandbox/index.html
@@ -50,6 +50,13 @@
iframe {
border: none;
}
+ .hint {
+ color: gray;
+ border-right: 1px solid #ccc;
+ padding-right: 10px;
+ margin-right: 5px;
+ box-shadow: 1px 0 white;
+ }
</style>
</head>
@@ -57,6 +64,7 @@
<div id=editor>
<div id=controls>
<button onclick="render()">Render</button>
+ <span class=hint>or press cmd/ctrl + enter</span>
<span id=docname></span>
</div>
<div id=save-load>
View
8 sandbox/sandbox.js
@@ -139,6 +139,14 @@ function loadFile() {
}
window.addEventListener("hashchange", loadFile, false);
+window.addEventListener("keydown", function(event){
+ console.dir(event);
+ // ctrl and enter = render
+ if((event.ctrlKey || event.metaKey) && event.which === 13) {
+ event.preventDefault();
+ render();
+ }
+});
function showError(msg) { alert(msg); }
Something went wrong with that request. Please try again.