Well, first of all, it won't compile. In your keyPressed method, you are calling getKeyText(), which requires an int as an argument. I suspect you meant to use getKeyChar().
Second, you need to add the KeyListener object to the component that is visible - that is, to the JTextField showkey, not to the container pane.
Try it.
You should see both your keyPressed and keyTyped event handlers for the character keys, and just your keyPressed for the non-typeable keys.
One more suggestion - while you're learning, you may want to include in your printout the name of method that is showing the information, such as "System.out.print("in keyPressed " + x);" or "System.out.print("in keyTyped " + key);". Helps you to learn the differences between a keyPressed, keyTyped, and keyReleased.
Have fun!