To Reset link on Anchor Tag on Enter Key Press

To Reset link on Anchor Tag on Enter Key Press

I have a Login page. After successfull Login user redirectes to Main Page that is a ASCX Page. I have used div elements in it.

<div title="Main" id="main">
            <a href="/Home.aspx" id="home">

                <div class="link-title">
                    Home
                </div>
            </a>
        </div>
        <div title="Contact" >
            <a href="/Contact.aspx" id="contact">

                <div class="link-title">
                    Contact
                </div>
            </a>
        </div>

I want to reset focus on Anchor Tag when Enter Key is pressed. I have used below mentioned code, but its not working.I want this feature should work on firefox browser.

 $(function () {

var el = document.getElementById('main');

if(el) {
    el.addEventListener("keydown", storeLinkId, false);

    //function stores ID attribute of target link
    //into session storage if enter is pressed    
    function storeLinkId(e) {
        if (!e) e = window.event;
        var keyCode = e.keyCode || e.which;

        if (keyCode == '13') {
            console.log("storing " + e.target.id);
            sessionStorage.setItem('tabbed-link', e.target.id);
        }
    }

    //if there is a linkid in session storage
    if (sessionStorage.getItem('tabbed-link')) {
        //get the id from session storage
        var linkId = sessionStorage.getItem('tabbed-link');
        //focus on the link with the matching id attribute
        document.getElementById(linkId).focus();
        //delete the linkid from session storage
        sessionStorage.removeItem('tabbed-link');
    }
}

});

Can please anyone assist me to fix this issue?