How would I listen for keypresses in a window?

I'm working on a game and want to grab keyboard input while a specific window is focused. It wont have many components, should just be a JTextArea(that can't be edited) though Ill probably add more as I get better with JFrames. How would I listen for the keyboard input? A key listener?
3 Replies
JavaBot
JavaBot10mo ago
This post has been reserved for your question.
Hey @blockgoblin31! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
blockgoblin31
blockgoblin31OP10mo ago
ok I just needed to add .setFocusable(true)
JavaBot
JavaBot10mo ago
Post Closed
This post has been closed by <@501514065068294154>.
Want results from more Discord servers?
Add your server