Results 1 to 8 of 8

Thread: Disabling keys

  1. #1
    Join Date
    Feb 2009
    Location
    SW Connecticut/NY area
    Posts
    9,181

    Default Disabling keys

    Anyone have any ideas on how to disable control keys in IE using JavaScript? Specifically Control+C & +V. This is NOT Ajax where I think there's some code to do that and I've used it to good effect -- but I don't have that option here.

    I've seen numerous articles on the Web but virtually all require some entry (onclick) in the input control to trigger it but I need it to be global for the page -- too many controls to modify each individually and I can't be tying up the onclick event.
    Bob Worsley
    203-249-2633
    rlworsley at gmail.com

    Do or do not. There is no try. — Yoda

  2. #2
    Join Date
    Feb 2009
    Location
    Adelaide, South Australia
    Posts
    165

    Default Re: Disabling keys

    Wouldn't you also then need to disable copying and pasting via the right click menu? As far as I can tell, there isn't really a good way to prevent people copying and pasting content on a website.
    Matt


  3. #3
    Join Date
    Feb 2009
    Location
    Queens, NY, NY
    Posts
    7,429

    Default Re: Disabling keys

    well if you want to prevent it to stop screen scrapers, I did a thing years ago where the important parts of the data were rendered into JPG files and dropped in as randomly named pictures of text. Looked real ugly if they Zoomed... But there was no way a script could pull out the data..

    :-)
    Michael Mullan.
    Danes Bridge Enterprises.

    ++++++++++++++++++++++++++++
    There is just today. Tomorrow is a concept
    that is mostly theoretical. -- GM Wylie
    ++++++++++++++++++++++++++++

  4. #4
    Join Date
    Feb 2009
    Location
    Hengelo, Netherlands
    Posts
    10,869

    Default Re: Disabling keys

    Bob,

    Instead of blocking the keys you better cancel the methods copy and paste for the controls. I quickly googled for solutions and one of the found pages was http://www.hypergurl.com/norightclick.html.
    Regards,
    Data Access Worldwide
    Vincent Oorsprong

  5. #5
    Join Date
    Feb 2009
    Location
    SW Connecticut/NY area
    Posts
    9,181

    Default Re: Disabling keys

    Thanks guys. Disabling the methods would of course be the best way but I didn't know I could even do that. Thanks Vincent, I'll check into it tomorrow when I'm back at work.
    Bob Worsley
    203-249-2633
    rlworsley at gmail.com

    Do or do not. There is no try. — Yoda

  6. #6
    Join Date
    Feb 2009
    Location
    SW Connecticut/NY area
    Posts
    9,181

    Default Re: Disabling keys

    In the end result I never did find a way to globally disable specific keystroke combinations or the copy/paste methods - what was provided in Vincent's link did work but not cover all for my situation. Disabling the right click floating menu did work as expected and adding the parameters to the body tag worked but I couldn't use it so ended up having to do it in the individual controls. Ich. Anyway, job done and thanks.
    Bob Worsley
    203-249-2633
    rlworsley at gmail.com

    Do or do not. There is no try. — Yoda

  7. #7
    Join Date
    Feb 2009
    Location
    Adelaide, South Australia
    Posts
    165

    Default Re: Disabling keys

    The problem with all of those Javascript solutions, is that it may keep the average Joe from copying text on your site, but anyone determined to get the text can bypass it by simply disabling Javascript.
    Matt


  8. #8
    Join Date
    Feb 2009
    Location
    SW Connecticut/NY area
    Posts
    9,181

    Default Re: Disabling keys

    No worries. The application is not public and is actually a small browser based training exam functionality where students take tests. The customer wanted to remove copy and paste, so minimal security on this is all that's necessary.
    Bob Worsley
    203-249-2633
    rlworsley at gmail.com

    Do or do not. There is no try. — Yoda

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •