The Ultrashock Ultra Bundle
  • Home
  • Community
  • Forum
  • Development
  • Client Side
  • Thread
  •  
  • Previous topic
  • Next topic
Sign up to post

Development
 Client Side

  • r_bartoli Author 
    • 8617 
    • 0 
    • 2 
    Disable CTRL key
    r_bartoli

    Last reply Jan 20 2008, 06:37 PM

    by r_bartoli

    Posted: Jan 20 2008, 05:48 PM

    by r_bartoli

     

Hi all,
I’m developing a RIA in Flash and i need to disable the input of CTRL key in the browser.
Someone know how to do it (I think using javascript)?

Thanks

  2 REPLIES
 
Anik
1  
Anik

google smilie

AS Workshop Disable ctrl + n and other ctrl + key combinations in JavaScript

  • 20 January 2008 06:07 PM
  •  
r_bartoli Author 
2  
r_bartoli

Thanks Anik, I’m using it now but it doesn’t work in IE7…

The script is this one:

<script language="JavaScript">
function 
disableCtrlKeyCombination(e)
{
        
//list all CTRL + key combinations you want to disable
        
var forbiddenKeys = new Array(&#8216;a&#8217;, &#8216;n&#8217;, &#8216;c&#8217;, &#8216;x&#8217;, &#8216;v&#8217;, &#8216;j&#8217;);
        
var key;
        var 
isCtrl;

        if(
window.event)
        
{
                key 
= window.event.keyCode;     //IE
                
if(window.event.ctrlKey)
                        
isCtrl = true;
                else
                        
isCtrl = false;
        
}
        
else
        
{
                key 
= e.which;     //firefox
                
if(e.ctrlKey)
                        
isCtrl = true;
                else
                        
isCtrl = false;
        
}

        
//if ctrl is pressed check if other key is in forbidenKeys array
        
if(isCtrl)
        
{
                
for(i=0; i<forbiddenkeys .length; i++)
                
{
                        
//case-insensitive comparation
                        
if(forbiddenKeys[i].toLowerCase() == String.fromCharCode(key).toLowerCase())
                        
{
                                alert
(&#8216;Key combination CTRL + &#8216;
                                        
+String.fromCharCode(key)
                                        +&
#8216; has been disabled.&#8217;);
                                
return false;
                        
}
                }
        }
        
return true;
}
</script> 

And I’m using it like this:

<body onkeypress="return disableCtrlKeyCombination(event);" onkeydown="return disableCtrlKeyCombination(event);" leftMargin="0" topMargin="0"> 

Any idea?

Thanks

  • 20 January 2008 06:37 PM
  •  
  •   Log in or join for free to make a comment.
 
Topic actions
  •  Share on Facebook
  •  Share on Twitter
Topic Categories
  •  Show All Topics
  •  Development
    •  Server Side
    •  Client Side
  •  Creative Software
    •  Web
    •  Video
    •  3D
    •  Illustrator
    •  Photoshop Battles
    •  Photoshop
  •  Design
    •  Typography
    •  Resources & Insight
    •  Checkpoint
  •  Career
    •  Copyright Matters
    •  Advice & issues
    •  Job Seekers
    •  Job Offers
  •  Flash
    •  UltraMath
    •  OOP
    •  Third Party Tools
    •  Open Source alternatives
    •  Data Communication
    •  Components
    •  Flex
    •  AIR
    •  Flash Lite
    •  Flash Professional
    •  Flash Newbie
    •  ActionScript
    •  XML
  •  Lounge
    •  Polls
    •  Random Chat
    •  Showcase And Critique
    •  BombShock Award Nominations
  •  Community Essentials
    •  BombShock Award Winners
    •  Tutorials
    •  Interviews
    •  News
    •  Bitmap tutorials
Popular Topics
  • Sort by: 
  • Activity
  • Views
  • Comments
  • Likes
Advertise with us
  • Your advertisement here!
  • loading
Ultrashock
  • Creative Assets
  • Community
  • Blog
  1. Home
  2. Forum
+/-
Creative Assets
  • Categories
  • Contributors
  • How to buy
Make Money
  • Commission Rates
  • Referral Program
  • Contributor Program
Community
  • Activity Feed
  • Forum
  • Profiles
About
  • Quick Tour
  • Our History
  • Banners & Logos
Support
  • Contact Ultrashock
  • Advertise with us
  • Legal Information
  •  Keep up to date
  • Flash 779  Flash
  • Audio 6,481  Audio
  • Vector 2,130  Vectors
  • Image 12,338  Images
  • Creative Assets 21,728  Assets
  • Profiles 282,751  Members
  • Topics 93,776  Topics
  • Blog 4  Blog
  • Facebook 1,679  Facebook
  • Twitter 1,163  Twitter
  • Join our FREE monthly newsletter!
  • Archive
  • Invalid email address. Please try again.
Subscribe
  • ©2012 Ultrashock LLC - All rights reserved
  • Terms of Use
  • Privacy Policy
  • Switch to dark theme
  • RSS Feeds
  • Top

©2012 Ultrashock LLC - All rights reserved

Printed on Sat, February 11, 2012 - 19:47:15