Ir para conteúdo

POWERED BY:

Arquivado

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

eriva_br

Js Para Chamar Evento No Lado Server

Recommended Posts

vi nesse tópico um esquema sobre rejeitar teclas, gostaria se saber se é possível com uma tecla de atalho tipo F8, chamar um evento no lado server da força, o evento seria um click de um botão

 

OBS.: o accesskey não aceitou F8, somente letras, ex. A, B, etc para formar o ALT+(letra)

Compartilhar este post


Link para o post
Compartilhar em outros sites

Handling Keyboard Shortcuts in JavaScript

 

Documentation

[*]Add Shortcut

[*]Remove Shortcut

<H3 id=add_docs>shortcut.add()</H3>First Argument : The Shortcut Key Combination - String The shortcut key combination should be specified in this format ... Modifier[+Modifier..]+Key. More about this in the Supported Keys section. Second Argument : Function to be called - Function Specify the function here. This function will be called if the shortcut key is pressed. The event variable will be passed to it. Third Argument[OPTIONAL] : Options - Associative Array This argument must be an associative array with any of these three options... type - String The event type - can be 'keydown','keyup','keypress'. Default: 'keydown' disable_in_input - Boolean If this is set to true, keyboard capture will be disabled in input and textarea fields. If these elements have focus, the keyboard shortcut will not work. This is very useful for single key shortcuts. Default: false target - DOM Node The element that should be watched for the keyboard event. Default : document propagate - Boolean Allow the event to propagate? Default : false keycode - Integer Watch for this keycode. For eg., the keycode '65' is 'a'. Example...

JAVASCRIPT
{'type':'keydown','propagate':false,'disable_in_input':true,'target':document,'keycode':65}

Example Code

JAVASCRIPT
shortcut.add("Ctrl+B",function() {      alert("The bookmarks of your browser will show up after this alert...");},{     'type':'keydown',       'propagate':true,       'target':document});
<H3 id=remove_docs>shortcut.remove()</H3>Just one argument - the shortcut combination that was attached to a function earlier. Make sure that this is exactly the same string that you used while adding the shortcut.

 

 

Example Code

JAVASCRIPT
shortcut.add("Ctrl+B",function() {      alert("Bold");});//Remove the shortcutshortcut.remove("Ctrl+B");
<H2 id=keys>Supported Keys</H2>The shortcut keys should be specified in this format ...

 

Modifier[+Modifier..]+Key Example...

 

Ctrl+A The valid modifiers are

[*]Ctrl

[*]Alt

[*]Shift

[*]Meta

You can specify a sequence without a modifier as well - like this...

 

JAVASCRIPT
shortcut.add("X",function() {

 alert("Hello!");

});

The valid Keys are...

[*]All alpha/numeric keys - abc...xyz,01..89

[*]Special Characters - Every special character on a standard keyboard can be accessed.

[*]Special Keys...

[*]Tab

[*]Space

[*]Return

[*]Enter

[*]Backspace

[*]Scroll_lock

[*]Caps_lock

[*]Num_lock

[*]Pause

[*]Insert

[*]Home

[*]Delete

[*]End

[*]Page_up

[*]Page_down

[*]Left

[*]Up

[*]Right

[*]Down

[*]F1

[*]F2

[*]F3

[*]F4

[*]F5

[*]F6

[*]F7

[*]F8

[*]F9

[*]F10

[*]F11

[*]F12

These keys are case insensitive - so don't worry about using the correct case.

 

This library is in beta - so expect some problems. Suggestions are welcome.

 

 

Code

Download the shortcuts.js file.

 

 

License

BSD License

 

 

Other Libraries

There is a jQuery plugin available for this library - jQuery Keyboard Hooker Plugin by Tzury Bar Yochay

 

 

fonte: http://www.openjs.com/scripts/events/keyboard_shortcuts/

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.