KeyListener not working?

I have been working on a game for a while and have been using keyListener. It always worked but lately keyPressed() is not always called. I used output statements to show which key function is being called. keyReleased() always works for some reason. I was just wondering if anyone could help me out with this weird problem. Thanks!

Edit: I am using JFrame by the way