Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Github Comment Enhancer) Keyboard shortcuts #19

Closed
jerone opened this issue Aug 30, 2014 · 11 comments
Closed

(Github Comment Enhancer) Keyboard shortcuts #19

jerone opened this issue Aug 30, 2014 · 11 comments

Comments

@jerone
Copy link
Owner

jerone commented Aug 30, 2014

https://github.com/ccampbell/mousetrap
https://github.com/jeresig/jquery.hotkeys

@thomaslevesque
Copy link

👍

@jerone
Copy link
Owner Author

jerone commented Apr 26, 2015

Took me some time to figure out, but I think I've got the shortcuts working great now.

The following shortcuts are supported:

  • Bold = ctrl+b*
  • Italic = ctrl+i*
  • Underline = ctrl+u
  • Strikethrough = ctrl+s
  • Header 1 = ctrl+1
  • Header 2 = ctrl+2
  • Header 3 = ctrl+3
  • Header 4 = ctrl+4
  • Header 5 = ctrl+5
  • Header 6 = ctrl+6
  • Link = ctrl+l*
  • Image = ctrl+g*
  • Unordered List = alt+ctrl+u
  • Ordered List = alt+ctrl+o
  • Task List = alt+ctrl+t
  • Code = ctrl+k*
  • Quote = ctrl+q*
  • Horizontal Rule = ctrl+r*
  • Table = alt+shift+t
  • Clear = alt+ctrl+x

*) Shortcut the same as on StackOverflow answer fields.

I'm not releasing this feature just yet, but if anyone interested you can try the development version: https://github.com/jerone/UserScripts/tree/Github_Comment_Enhancer/Github_Comment_Enhancer

@thomaslevesque
Copy link

Awesome! I was considering trying to do it myself, but I'm not proficient in Javascript so I'm not sure I would have succeeded...

I noticed that some of the shortcuts you picked conflict with pre-defined browser shortcuts, which should be avoided if possible:

  • ctrl+c is traditionally reserved for "Copy", so it's probably not a good idea... Stackoverflow uses ctrl+k, which seems a good choice to me
  • ctrl+s is mapped to "Save" in most browsers
  • ctrl+t is mapped to "New tab" in most browsers
  • ctrl+shift+t is mapped to "Reopen closed tab" in most browsers

Also, I don't think that we need a shortcut for each and every command, just for the most common. For instance, to write a horizontal line you just need to type "***", so the shortcut isn't very useful; I'd rather have ctrl+l be used for Link (as on Stackoverflow), because it's more obvious than ctrl+shift+w, and not have any shortcut for Line.

jerone added a commit that referenced this issue Apr 26, 2015
@jerone
Copy link
Owner Author

jerone commented Apr 26, 2015

Thank you for your feedback!

I noticed that some of the shortcuts you picked conflict with pre-defined browser shortcuts, which should be avoided if possible:

All shortcuts are caught in only the comment fields, where the default behavior is prevented. For example ctrl+s won't open the save dialog for the page when pressed in the comment field.

ctrl+c is traditionally reserved for "Copy", so it's probably not a good idea... Stackoverflow uses ctrl+k, which seems a good choice to me

Should have seen that!

I'd rather have ctrl+l be used for Link (as on Stackoverflow) [...]

Good suggestion to look at StackOverflow, didn't know they had shortcuts too.

I've updated above list with the new shortcuts.

@thomaslevesque
Copy link

Perfect !

And thanks for writing this script, it makes writing on Github so much easier

@jerone
Copy link
Owner Author

jerone commented Apr 26, 2015

Thanks for using! I've got more userscript for GitHub that make things just a bit easier.

If you've got other features or feedback, feel free to open an issue. And sometimes I need another push 😄

@jerone jerone self-assigned this Apr 26, 2015
@thomaslevesque
Copy link

Is the user script supposed to work on Chrome as well? It shows the buttons, but they don't do anything and the keyboard shortcuts don't work.

@thomaslevesque
Copy link

If I use Tampermonkey to install the script, the buttons work, but the shortcuts don't

@jerone
Copy link
Owner Author

jerone commented Apr 27, 2015

Thanks for testing! There were some issues with Chrome that needed attention. One of those issues resulted in new shortcuts. I have updated above list with the new combinations.

It should now work in both Firefox and Chrome.

@thomaslevesque
Copy link

Yes, it works 👍

Thanks!

@jerone
Copy link
Owner Author

jerone commented Apr 27, 2015

@thomaslevesque commented on 27 apr. 2015 17:52 CEST:

Yes, it works 👍

Haha

The only one I'm not happy with is table alt+shift+t. But both ctrl+t & ctrl+shift+t can't be overridden in Chrome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants