Search

11/01/2013

javascript - How does Trello access the user's clipboard? - Stack Overflow

javascript - How does Trello access the user's clipboard? - Stack Overflow - 複製要先按下ctrl+c, 按下ctrl鍵之後, 動態產生一個看不到的textarea, 裡面是要複製的東西, 然後focus到textarea, 使用者按下 c 之後自然會複製裡面的東西 http://stackoverflow.com/questions/17527870/how-does-trello-access-the-users-clipboard

We don't actually "access the user's clipboard", instead we help the user out a bit by selecting something useful when they press Ctrl+C. Sounds like you've figured it out; we take advantage of the fact that when you want to hit Ctrl+C, you have to hit the Ctrl key first. When the Ctrl key is pressed, we pop in a textarea that contains the text we want to end up on the clipboard, and select all the text in it, so the selection is all set when the C key is hit. (Then we hide the textarea when the Ctrl key comes up)

沒有留言: