kiichi / QuickCopyTitleAndURL

Quickly copy Title and URL from Chrome Toolbar.
MIT License
26 stars 3 forks source link

idea: keyboard shortcuts for copycat #11

Closed jeske closed 4 years ago

jeske commented 4 years ago

I use copycat so much, I would really like if there was a keyboard shortcut for it, instead of having to constantly interact with the pulldown selection.

Here is one idea of how it could work:

A. Global Hotkey to open the pulldown (alt-shift-c ? configurable in an options page?)

B. Local Hotkey Each copy type would get a number. while the CopyCat popup is open, pressing the number will act as if that type was clicked on with the mouse, and close the pulldown.

(B) could be used without doing (A). Meaning one could click on the popup, and then hit "4" on the keyboard to choose "copy rich text link"

Advanced Ideas

tomnielsen commented 4 years ago

Chrome supports "activating" extension using: chrome://extensions/shortcuts (found via the hamburger menu in the upper left of the Extensions page chrome://extensions)

Then I guess when the popup window is active, you can try to capture keyboard shortcuts using javascript in the extensions popup page.

This post is a bit of overkill but does hotkey handling: https://medium.com/better-programming/full-featured-hotkeys-library-in-200-lines-of-javascript-code-81a74e3138cc

kiichi commented 4 years ago

Thank you for your feedback, I'll look into those hotkeys features!

kiichi commented 4 years ago

It seems they already have out-of-box API here, and those shortcut keys are available

chrome.commands - Google Chrome

kiichi commented 4 years ago

I got hot-key working, Command+Shift+C is bringing debug console so I'm thinking using Command+Shift+P. I also figured I needed reload chrome extension for testing, some voodoo reloading stuff. It's impossible to popup menu programmatically without user interaction. This make sense, all playing sound API, etc... requires the user to click on the screen first. Only the way is to popup modal window or new tab, which defeats the purpose of this plugin to copy Title.

One solution is using Notification as if it's like Toastr message, but it could be annoying if it's not transparent. Instead, I'm thinking "Remember the last selection" and Ctrl+Shift+P to repeat the previous action.

kiichi commented 4 years ago

A few updates on this PR #14

First of all, Chrome doesn't allow popup something without user interaction using mouse. This is common security feature and I saw similar behavior for auto-playing sound and so on. So I decided to implement HotKey / Shortcuts based on previous selection. This should serve most of use case. For example, you are editing Markdown, you might be keep adding links in Markdown format.

Current candidates for shortcuts:

Windows: Alt+Shift+C Mac: Ctrl+Shift+C (Alt key is not translated in Mac? Option Key didn't load somehow)

notification idea__keyboard_shortcuts_for_copycat_·_Issue__11_·_kiichi_QuickCopyTitleAndURL

Demo

kiichi commented 4 years ago

Ok here is the updated shortcut key features in v1.5.0

Quick Copy (Use previously selected format)
- Windows: Alt+Shift+C (Single Tab) / Alt+Shift+A (All Tabs)
- Mac: Ctrl+Shift+C (Single Tab) / Ctrl+Shift+A (All Tabs)
jeske commented 4 years ago

awsome! I'm looking forward to trying it out!

jeske commented 4 years ago

Ohh, I just read your notes about "using the last selection" for the hotkey... I can't speak for other users, but this mystery-context-sensitivty is not going to work for me.

I'm about 60% Rich Text, 39% Markdown, 1% others. And I most frequently only grab one link per compose session. (80% of sessions are only 1 link) I'm not going to remember "which format I used last", so because of this "use last model" I'm still always going to have to use the menu.

I would prefer other models, like:

kiichi commented 4 years ago

@jeske I hear you, I'm going to implement settings soon. I can reserve max 4 shortcuts and I'll make them customizable.

For now, how about those 4 keys

Let me add Rich Text and Markdown today, I'm updating one more version for the context menu, and this should help you for quick solution before working on the setting screen. I think it's better than cycle since you can hit in one-stroke (Alt+Shift+R or Alt+Shift+M). I also agree that I often use those 2 items.

Yeah, I was thinking re-order menu items too, I added it in my todo list. Feature Requests I'll research about capturing key while popup is open. I'm expecting Chrome Extension can do same key event handling like regular browser window.

kiichi commented 4 years ago

Btw, I just put those shortcuts and in this early stage, I don't mind changing those default shortcut keys (I don't think other users will complain either). Does Alt+Shift+M is bad choice for you since I am forcing you to use both hands?

It's easy to remember, and my workflow is usually copy into chat tools after Alt+Tab then past it.

jeske commented 4 years ago

ALT-SHIFT-R shortcut seems good.

No, I don't think I'd use two handed shortcuts like alt-shift-M. My most common use of this is with gmail (or github). Typically I go into another browser window, either to find an existing tab, or search the web for a page I already knew about, mouse-copycat to grab link, mouse-click directly back into the composer insertion point (I'm usually on a desktop dual monitor setup with lots of space for windows), then control-V to paste.

Here are some more thoughts on this topic...

I would remove the "repeat last" concept entirely. The problem is, the last time a user used copycat could be hours or even days ago. How would they remember and know what repeat-last is even going to do? Repeat-last is more something used to repeat something complex a bunch of times quickly, like in emacs, where I record a weird complex sequence of editing actions, and then spam repeat-last 15 times to do the same thing on a bunch of successive lines. In this case i's more like "repeat the thing I did in the last ~30 seconds, otherwise do nothing".

I would drop the all-tabs shortcuts, and certainly not make them default, because this doesn't seem like a common use case. I've never used the feature at all, even from the menu. Is this something you use?

If it was me, I would setup 2-3 shortcuts for the most commonly used options, and defer anything else for when there is a settings page. Something like:

kiichi commented 4 years ago

ok make sense, let me put those 4 keys and I'll set default actions.

kiichi commented 4 years ago

I submitted, I kept the previous copy in Alt+Shift+Z, those shortcuts will be configurable via settings screen soon.

Here is the list of current settings


Copy Rich Text:
- Windows: Alt+Shift+C
- Mac: Ctrl+Shift+C

Copy Markdown:
- Windows: Alt+Shift+D
- Mac: Ctrl+Shift+D

Copy Title - URL:
- Windows: Alt+Shift+X
- Mac: Ctrl+Shift+X

Repeat previous copy format:
- Windows: Alt+Shift+Z
- Mac: Ctrl+Shift+Z
jeske commented 4 years ago

sounds great!

kiichi commented 4 years ago

OK it's published. Please try now.

jeske commented 4 years ago

unfortunately, the shortcuts are not working for me in the new version on windows 10. I'll load it unpacked and see if I can figure out what's going on.

jeske commented 4 years ago

I guess the alt-shift-C shortcut isn't available by default on windows?

I went into chrome://extensions/shortcuts and it was empty... However, after assigning it, there, it works great!

image

jeske commented 4 years ago

As another note.... it has a shortcut called "Activate the Extension" which activates the popup. I wonder if this can be used to do the original idea, of having a shortcut to activate the extension, and then a number key for the type of the copy.