Friday, December 13, 2024

Implement the functions of shortcut keys Ctrl+S and Ctrl+Esc using JavaScript

 The following is the specific code: 83 is the key value of the S key, and 27 is the key value of the Esc key

document.onkeydown = fnPortfolioKeyCheck;

function fnPortfolioKeyCheck(evt)

{

    evt = (evt) ? evt : window.event;

    if (evt.ctrlKey)

    {   

        if (83 == evt.keyCode)

        {

            goToPortfolioSaverPage();

        }

    }

    else if (27 == evt.keyCode)

    {

        if ("" == document.getElementById("showCompanyLookupId").style.display)

        {

            document.getElementById("showCompanyLookupId").style.display = "none";

            document.getElementById('divMask').style.display='none';

        }

        if ("" == document.getElementById("showPortfolioBrowserId").style.display)

        {

            document.getElementById("showPortfolioBrowserId").style.display = "none";

            document.getElementById('divMask').style.display='none';

        }

    }

}

No comments:

Post a Comment