x

How to disable the FUNCTION KEYS

@Adam  @Bernadette @NJRFTF 

Hi   greetings from Kenya

I am using the disable right click and disable keyboard short cuts  like CTRL P   with good effect.

But a friend was troubleshooting weird twitter card stuff and he said, u gave the twitter cards   3 times on 1 page.

I asked him how he saw that.   He was pressing F11   or F12     to see my source code.   Like u do when u right click and INSPECT

is there any code for disabling that???

Cheers   whitemonkey   

2,478 Views
Message 1 of 8
Report
1 Best Answer

Best Answer

@NJRFTF 

Ok i got it.....

I am now using:    <script type="text/javascript"> document.onkeydown = function (event) { event = (event || window.event); if (event.keyCode == 123 || event.keyCode == 18 || event.keyCode == 17 || event.keyCode == 67 || event.keyCode == 16) { alert("This function is disabled here"); return false; } } </script>

123 blocks F12,   18 blocks ALT   17 blocks CTRL  16 blocks SHIFT keys           extra security  67 blocks c

This is a great source    @Adam  and @Bernadette   :   https://css-tricks.com/snippets/javascript/javascript-keycodes/

But   my buddy can hit f12     many times and it works     but he is a tech guy      ..    was quite shocking what he could do ...    but  these blocks   stop 99% of people    

Best regards    stay safe, stay at home   and stay sane       . I am 'stuck in KENYA   until July 5    Smiley Sad(((((

🙊🙉🙈

View Best Answer >

2,431 Views
Message 9 of 8
Report
7 REPLIES 7

@whitemonkey 

Disable F12 - place the following in SEO Header...

<script type="text/javascript">

document.onkeydown = function (event)
{
     event = (event || window.event);
     if (event.keyCode == 123 || event.keyCode == 18)
     {
           alert("This function is disabled here");
           return false;
     }
}
</script>

F11 key (in Windows) in most browser windows will switch full-screen mode and disabling that is likely to upset some viewers!! 🙂   Not sure how he can use F11 to view code?

2,458 Views
Message 4 of 8
Report

@NJRFTF   thank you      sadly it didnt work    for the F12.           I have the other code pasted as well. The one that disables CTRL keys    in the HEADER    

Right click is in the FOOTER....   

2,453 Views
Message 4 of 8
Report

@whitemonkey 

Here's my "F12 disabled" message box in Chrome on a weebly page...your scripts may be bumping heads!! 🙂

image

2,446 Views
Message 9 of 8
Report

Hi @NJRFTF    bit of a long saga here

The code u gave me     works   if i delete the CTRL C code i had in there, which was working    and now apparently doesnt work       Smiley Sad((

But this  f12        if  you hit F12 twice     u can see the source code...   

This is the code i was using to block keyboard short cuts     but doesnt block ctrl , now at least      am not sure if it was blocking print screen or other ctrl functions:

<script type="text/javascript">
document.onkeydown = function (cc) {
if(cc.which == 85){
return false;
}
if(cc.which == 80){
return false;
}
}
</script>

2,433 Views
Message 9 of 8
Report

Best Answer

@NJRFTF 

Ok i got it.....

I am now using:    <script type="text/javascript"> document.onkeydown = function (event) { event = (event || window.event); if (event.keyCode == 123 || event.keyCode == 18 || event.keyCode == 17 || event.keyCode == 67 || event.keyCode == 16) { alert("This function is disabled here"); return false; } } </script>

123 blocks F12,   18 blocks ALT   17 blocks CTRL  16 blocks SHIFT keys           extra security  67 blocks c

This is a great source    @Adam  and @Bernadette   :   https://css-tricks.com/snippets/javascript/javascript-keycodes/

But   my buddy can hit f12     many times and it works     but he is a tech guy      ..    was quite shocking what he could do ...    but  these blocks   stop 99% of people    

Best regards    stay safe, stay at home   and stay sane       . I am 'stuck in KENYA   until July 5    Smiley Sad(((((

🙊🙉🙈

2,432 Views
Message 9 of 8
Report
Square

This all went over my head, @whitemonkey but wanted to say HI and hope you are well. Heart 

2,362 Views
Message 9 of 8
Report

@Bernadette   hi.

The trick with the coding.... dt try to understand it.... just accept it as what u have to do.. lol   

I am well.    Hope you are too.

Going a bit stir crazy....    people offering advice   like    Fly to, Thailand.  Check the flight departures on line from Nairobi..... what part of THE AIRPORT IS CLOSED dt they get... ....?? Ok they have been some evac flights   too expensive, requiring expensive covid test and taxi ride to get to Nairobi.  UK now requires quarantine    but have no where to go in UK...    other countries are slowly opening up...   soon there will be a heap of choices...   so i continue to wait..   and hope they open here...

Take care there   Trev ❤

2,321 Views
Message 9 of 8
Report
This thread has been archived and locked. Please start a new thread if you would like to continue the conversation.