HTML5 Fullscreen API escape button event

I’m using jQuery fullscreen plugin https://github.com/martinaglv/jQuery-FullScreen
My code:

$  ('#cancel-fullscreen').hide()
//View Fullscreen
$  ('#view-fullscreen').click(function(){
    $  ('#container').css({'background': 'green'}).fullScreen();
    $  (this).hide();
    $  ('#cancel-fullscreen').show();
    return false;
});

//Cancel Fullscreen
$  ('#cancel-fullscreen').click(function(){
    //I need this work when "Esc" or "F11" buttons pressed
    $  ('#container').css({'background': 'red'}).fullScreen(); //If press "Esc" background still green..
    $  (this).hide();
    $  ('#view-fullscreen').show();
    return false;
});

It works good, but I do not need “Cancel” button in my design, fullscreen is canceling good with pressing “Esc” or “F11″ buttons. And I need to run some function after this buttons was pressed, any ideas how can it be done?

Thanks,
Kuzzy.

newest questions tagged jquery – Stack Overflow

About Admin