ok im doing a tetris game and i want the piece to move left when i click 'a' and right when i click 'd' and turn clockwise when i click 'w' and turn counterclockwise when i click 's'. heres what i have

public class Movement extends JPanel implements KeyListener {

        public Movement (){

         public void keyTyped (KeyEvent e){
                 if (e.getKeyCode == 'a')
                       //shift left code
                 else if (e.getKeyCode == 'd')
                       //shift right code
                 else if (e.getKeyCode == 'w')
                       //rotate clockwise code
                 else if (e.getKeyCode == 's')
                       //rotate counterclockwise code
          //irrelevant keyPressed and key Realeased methods that i dont do anything in

in the frame i use the built in keyTyped method to call

       move.keyTyped(evt)//evt being the KeyEvent the method uses

however it is not reading the keys being typed any key being typed for that matter. Please help!

And... ?

You haven't stated a question. Also, why would Movement be a class of it's own? A class encapsulates state and behavior. What state and behavior would be represented by Movement?

Edit: It looks like your post got cut off initially and you have added more to it, so the part about no longer really applies. The rest does though.

wat i want is that the Movement class should implement the KeyListener interface and read the keyboard when a key is TYPED, not pressed or released, and then proceeds to process that KeyEvent. If that KeyEvent happens to be an 'a','d','w','s' do a specific action to the Tetris piece. Now i had this initially working when it was just the frame and the movement class, but i moved both of those to a different file with my other class for this project and now it doesn't work. I then went back to my old one which i hadn't touched in several days and that did not work, i am very confused

P.S. This only my second year programming and im relativily new to graphics, animation and reading keyboards

Given that KeyListener is somewhat sensitive to component focus issues, it's often easier to use the InputMap and ActionMap of the root pane of the top level window (JFrame most likely). This is done by registering the keystroke inputs to actions like so:

      KeyStroke.getKeyStroke("A"), "MoveLeft");
    getRootPane().getActionMap().put("MoveLeft", new AbstractAction() {
        public void actionPerformed(java.awt.event.ActionEvent e) {
            // move left

ok i tryed KeyBinders before but i could not get it to work, ill try this, but where exactly should it go, in the Movement class? or directly into the keyTyped method of the frame?

Not knowing a thing about how you structured your program I really couldn't say. You need to register the input keys and their actions with the top-level window. How you go about that depends on the rest of your structure. It has nothing at all to do with keyTyped. It's a separate input-action model altogether.

Actually, you don't even need to put them on the top-level window. I had a slightly different scenario in mind when I suggested that. You can bind them to whatever panel you are drawing to for the game screen. Perhaps this tiny example will help

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.geom.Ellipse2D;
import javax.swing.AbstractAction;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.KeyStroke;

public class KeyDemo extends JFrame {

    public KeyDemo(){
        DisplayPanel display = new DisplayPanel();
        getContentPane().setLayout(new BorderLayout());
        getContentPane().add(display, BorderLayout.CENTER);
        setSize(200, 150);
    class DisplayPanel extends JPanel{
        private Ellipse2D.Float ellipse;
        public DisplayPanel(){
                KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0),"MoveLeft");
            getActionMap().put("MoveLeft", new MoveLeftAction());
                KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0),"MoveRight");
            getActionMap().put("MoveRight", new MoveRightAction());

        protected void paintComponent(Graphics g) {
            Graphics2D g2 = (Graphics2D)g;
            g2.clearRect(0, 0, getWidth(), getHeight());
            if (ellipse==null){
                ellipse = new Ellipse2D.Float(
        class MoveLeftAction extends AbstractAction{
            public void actionPerformed(ActionEvent e) {
                if (ellipse.x>2){
                    ellipse.x -= 2;
        class MoveRightAction extends AbstractAction{
            public void actionPerformed(ActionEvent e) {
                if (ellipse.x < (getWidth()-ellipse.width-2)){
                    ellipse.x += 2;
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                new KeyDemo();