Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

rocborges

Bloquear tecla ALT

Recommended Posts

Uso o código abaixo para bloquear as teclas F5, ctrl n e ctrl f do teclado na minha página.

 

Estou tentando implementar o bloqueio da tecla ALT mas ta difícil.

 

alguém tem alguma dica?

 

<script language="JavaScript"> 
var placar = 0;
var competicao = 106;
c = navigator.appVersion.toLowerCase();
if (c.indexOf("msie 5") != -1)
  document.write('<link href="styles-ie5.css" rel="stylesheet" type="text/css" />');

function showDown(evt) 
{
	evt = (evt) ? evt : ((event) ? event : null);
	
	if (evt) 
	{
		if (navigator.appName=="Netscape") 
		{
			if (evt.which == 116) 
			{
				// When F5 is pressed
				cancelKey(evt);
			}
			else if (evt.ctrlKey && (evt.which == 82)) 
			{
				// When ctrl is pressed with R or N
				cancelKey(evt);
			}
		}
		else
		{
			if (event.keyCode == 116) 
			{
				// When F5 is pressed
				cancelKey(evt);
			}
			else if (event.ctrlKey && (event.keyCode == 78 || event.keyCode == 82)) 
			{
				// When ctrl is pressed with R or N
				cancelKey(evt);
			}
		 }
	}
}

function cancelKey(evt) 
{
	if (evt.preventDefault) 
	{
		evt.preventDefault();
		return false;
	}
	else 
	{
		evt.keyCode = 0;
		evt.returnValue = false;
	}
}

if (navigator.appName=="Netscape") 
document.addEventListener("keypress",showDown,true);


document.onkeydown  = showDown;

</script>

Compartilhar este post


Link para o post
Compartilhar em outros sites

a altkey e uma tecla especial entao e da seguinte forma

 

 

 

.................>>>

if(evento.altKey) {

alert('Premiste a tecla alt');

}

...............<<<<

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.