I am using `command + h` as a shortcut key in my website. It is not doing the function to be done. After I click something on the window only it works flawlessly. Here is my code..

```
window.onkeydown = function(event) {
    if (event.keyCode == 72 && (event.metaKey == true)) { 
        //some function
    }
}

```

Somebody try to rectify . I have included this code only after the dom gets loaded