[GREENFOOT-60] Numeric keypad does not work, and related key problems
To check whether the a-key is down you have to write Greenfoot.isKeyDown("A");
Also, the numbers entered via the keypad doesn't work.
---- Comment 1 From Davin McCall 2007-03-19 04:51:08
What is the desired behavior for the number pad keys? Do they act as numbers or arrows, or should they be entirely different key names (eg "np8", "np3" ...)?
It would be nice if we could make them act as cursor keys if numlock is off, or arrows if it is on, but there doesn't seem to be any way to get the status of numlock.
---- Comment 2 From Poul Henriksen 2007-03-20 09:15:55
Subject: Re: isKeyDown only works with upper case characters, and does not work with numeric keypad
If there is no way to get the numlock status, the number pad should just map to the numbers.
---- Comment 3 From Davin McCall 2007-03-21 03:51:31
Hmm, it turns out we can get numlock status via Toolkit.getDefaultToolkit().getLockingKeyState()... except on linux, it throws UnsupportedOperationException.
I've tried to fix this so that it translates according to numlock status (except on linux, it always assumes numlock is ON) but I've no idea how portable this is across operating systems and keyboard layouts etc. I really wonder if it might have been better to have different names for the keypad keys.
(It seems on linux, keypad 7/9/1/3 are automatically mapped to the correct key, but 8/4/6/2 are mapped to VK_KP_UP/LEFT/RIGHT/DOWN; VK_NUMPAD_x keys aren't used at all).
Let's see if this works on Mac/Windows...
---- Comment 4 From Poul Henriksen 2007-03-21 15:40:37
Subject: Re: isKeyDown only works with upper case characters, and does not work with numeric keypad
I get the UnsupportedOperationException on the Mac too. I think we should just map it directly to the numbers. If people want to use the keypad as arrows, they just have to program it to use the numbers.
Issue metadata
- Issue type: Bug
- Priority: Medium
- Fix versions: 3.0.0