bagaimana melihat apakah jendela memiliki fokus di js

var focused = document.hasFocus();
Selfish Snake