SORU
30 Temmuz 2010, Cuma


Nasıl JavaScript ile escape tuşuna basın algılamak için?

Olası Çoğalt:
Which keycode for escape key with jQuery

Nasıl YANİ içinde escape tuşuna basın algılamak için, Firefox ve Chrome? Aşağıdaki kod IE çalışır ve 27 ama firefox 0 uyarılar uyarılar

$('body').keypress(function(e){
    alert(e.which);
    if(e.which == 27){
        // Close my modal window
    }
});

CEVAP
30 Temmuz 2010, Cuma


$(document).keyup(function(e) {
     if (e.keyCode == 27) { // escape key maps to keycode `27`
        // <DO YOUR WORK HERE>
    }
});

Which keycode for escape key with jQuery

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Marina and The Diamonds

    Marina and T

    8 Temmuz 2008
  • Murray Winiata

    Murray Winia

    2 ŞUBAT 2009
  • Tek Syndicate

    Tek Syndicat

    23 Temmuz 2008