Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Julien-Lynge · Mar 05, 2013 at 08:39 PM · webplayercopycopy-pastepaste

Copy/Paste Key Combos in Webplayer

I'm implementing copy and paste functionality in our app. I found a thread that addresses getting info from the system clipboard and tested it out; it appears to work fine:

http://forum.unity3d.com/threads/24101-Copy-TextField-or-TextArea-text-to-Clipboard

Now I'm working on recognizing when the user has pressed a copy/paste key combo (like Control-V). In the standalone application, Input.GetKey* works just fine. I can check if the user is holding down the control/command key and presses C or V, and act accordingly.

However, in the webplayer and editor, this is not the case. It looks like the surrounding application (editor or browser) is catching the copy/paste key combinations and isn't passing them on to Unity. I can see control presses, I can see V presses, but I get no notification when the user presses control-V.

I've seen some discussion in other threads (like this one: http://answers.unity3d.com/questions/49285/how-can-i-get-a-combination-of-keys-pressed.html ), and have some things to try, but I'm hopeful that someone else has already figured this out and can save me the pain.

So, the question: is there any way to determine if the user has pressed control-v in the webplayer? If not, is there any way to get notice from the browser when the user copies or pastes?

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Julien-Lynge · Jun 19, 2013 at 04:25 PM 0
Share

Update: submitted bug 542262 to Unity concerning this a while back. They have been able to reproduce and sent it to the dev $$anonymous$$m. Since there's no date on when/if it will be fixed, I would still appreciate any workarounds that others have found.

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by soso · Dec 21, 2013 at 06:08 AM

using UnityEngine;

using System.Collections;

public class CopyPasteAct : MonoBehaviour

{

 TextEditor mTe = null;

 public static string copyPasteInfo = "";

 void Awake()
 {
     mTe = new TextEditor();
 }

 void OnGUI()
 {
     Event e = Event.current;
     if (e.type == EventType.KeyDown && e.control)
     {
         if (e.keyCode == KeyCode.C)
         {
             // Copy
             mTe.content = new GUIContent(copyPasteInfo);
             mTe.SelectAll();
             mTe.Copy();
         } else
         if (e.keyCode == KeyCode.V)
         {
             // Paste
             mTe.content.text = "";
             mTe.Paste();

             copyPasteInfo = mTe.content.text;
         }
     }
 }

}

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Julien-Lynge · Dec 21, 2013 at 06:18 PM 0
Share

Thank you, @soso!

I just verified that this works in both the editor and webplayer for detecting the ctrl-v combo and retrieving the text.

It looks like they've partially addressed the issue - you can now detect the ctrl-v combo with Input.Get$$anonymous$$ey in both standalone and webplayer (according to my quick test). However, your solution is still the only one that seems to work in the editor, which is very nice.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

12 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to copy to system clipboard? 2 Answers

How can I add Copy/Paste clipboard support to my game? 6 Answers

Copy Material 1 Answer

How to enable copy/paste/delete for programatically selected objects? 1 Answer

Clipboard pasting twice into InputField on Mac build 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges