Listening to Keyboard while using OpenGL

I have just started using OpenGL and I need to be able to listen to the keyboard.
Earlier I used to make a boolean[] (of length 8192) and add a KeyListener. Then I’d just set it so that the information would get put into the array. Like this:


buttonsPressed = new boolean[8192];
		frame.addKeyListener(new KeyListener() {
			
			@Override
			public void keyTyped(KeyEvent e) {/*Not used*/}
			
			@Override
			public void keyPressed(KeyEvent e) {
				buttonsPressed[e.getKeyCode()] = true;
			}
			
			@Override
			public void keyReleased(KeyEvent e) {
				buttonsPressed[e.getKeyCode()] = false;
			}
		});

Now I wonder, how am I supposed to do the same thing with OpenGL?
I have no idea how to do this, can you just go “Display.addaddKeyListener(new KeyListener()…” maybe? (I find that a bit unlikely)