Skip to content
This repository has been archived by the owner on Jun 27, 2018. It is now read-only.

Add keyboard shortcut for Format and Share #291

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add keyboard shortcut for Format and Share
Following a similar idea of #52, I'd like to add 2 shortcuts for Format and Share (ShortenUrl) buttons:
- `Ctrl-Alt-F` for the `Format` button
- `Ctrl-Alt-S` for the `Share` button

Tested with the docker local setup and Firefox/Chrome on LinuxMint 18

Current limitation:
- only work when editor is focused (similar to `Ctrl+Enter` for `Run`, but in that case the editor is focused when it's not)
hoangtranwork authored Jun 5, 2017
commit 1ffdedfd72e06a215a434dc8bfbf65bf5056dca5
10 changes: 10 additions & 0 deletions static/web.js
Original file line number Diff line number Diff line change
@@ -804,10 +804,20 @@
format(result, session, getRadioValue("version"), formatButton,
getRadioValue("optimize"), backtrace.value);
};
editor.commands.addCommand({
name: "format",
exec: formatButton.onclick,
bindKey: {win: "Ctrl-Alt-F", mac: "Ctrl-Alt-F"}
});

shareButton.onclick = function() {
share(result, getRadioValue("version"), session.getValue(), shareButton, backtrace.value);
};
editor.commands.addCommand({
name: "share",
exec: shareButton.onclick,
bindKey: {win: "Ctrl-Alt-S", mac: "Ctrl-Alt-S"}
});

gistButton.onclick = function() {
shareGist(result, getRadioValue("version"), session.getValue(), gistButton, backtrace.value);