Hacker News new | ask | show | jobs
by dhruvtv 4698 days ago
(Copy-pasting my answer from the same Stackoverflow thread)

I actually built a Chrome extension - https://chrome.google.com/webstore/search/copy%20link%20addr... that does exactly this, and for all web pages. GitHub source https://github.com/dhruvvemula/copylinkaddress/blob/master/c...

I find three bugs with Trello's approach, which I know because I've faced them myself :)

The copy doesn't work in these scenarios:

1. If you already have Ctrl pressed and then hover a link and hit C, the copy doesn't work.

2. If your cursor is in some other text field in the page, the copy doesn't work.

3. If your cursor is in the address bar, the copy doesn't work.

I solved #1 by always having a hidden span, rather than creating one when user hits Ctrl/Cmd.

I solved #2 by temporarily clearing the zero-length selection, saving caret position, doing the copy and restoring caret position.

I haven't found a fix for #3 yet :) (For info, check the open issue in my Github project - https://github.com/dhruvvemula/copylinkaddress/issues/1).