Input.GetKey(KeyCode.LeftShift) not working with Keypad numbers

Hello,

I am new to this forum and until now I have been working on a hobby project - a solar system/night sky simulator - since late March now and have found a lot of help from existing topics and discussions here. This is an awesome and active community. I love it!

Today I think I may found a bug, since I couldn’t find any evidence of whether this behavior is intended.
In my simulation I use/would like to use a couple of key combinations for debugging purposes. One of them is to progress the simulation time in a convenient way, using different key modifiers to distinguish between days, month and years as well as going backwards or forwards in time. In addition to that I use the keypad keys for the actual numeric values (e.g. Control+Shift+Keypad 3 should advance the simulation time by 3 years)

Currently my code looks like this:

double progressSecondsInSimulation = 0.0;
double progressTimeMultiplier = 1.0;
float progressTimeSign = 1f;
int progressTimeValue = 0;

/* forum note: the following if statements regarding progressTimeMultiplier were in a combined if-else-block and in reverse order previously, however this isn't the cause of my problem.
The convenient way I was talking about intends the setting of three numeric values that are multiplied at the end to avoid redundant and nested if-blocks */

// progress hours
progressTimeMultiplier = SECONDS_PER_HOUR;

// progress days
if((Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)))
    progressTimeMultiplier = SECONDS_PER_DAY;

// progress months
if((Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)))
    progressTimeMultiplier = SECONDS_PER_DAY * DAYS_PER_MONTH;

// progress years
if((Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) && ((Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))))
    progressTimeMultiplier = SECONDS_PER_DAY * DAYS_PER_YEAR;

// progress reversely
if(Input.GetKey(KeyCode.LeftAlt))
    progressTimeSign = -1f;

if(Input.GetKeyDown(KeyCode.Keypad1))
    progressTimeValue = 1;
else if(Input.GetKeyDown(KeyCode.Keypad2))
    progressTimeValue = 2;
else if(Input.GetKeyDown(KeyCode.Keypad3))
    progressTimeValue = 3;
else if(Input.GetKeyDown(KeyCode.Keypad4))
    progressTimeValue = 4;
else if(Input.GetKeyDown(KeyCode.Keypad5))
    progressTimeValue = 5;
else if(Input.GetKeyDown(KeyCode.Keypad6))
    progressTimeValue = 6;
else if(Input.GetKeyDown(KeyCode.Keypad7))
    progressTimeValue = 7;

progressSecondsInSimulation = progressTimeValue * progressTimeSign * progressTimeMultiplier;

if(progressTimeValue > 0)
    Engine.ProgressTime(progressSecondsInSimulation, false);

The combinations with Control (progress days) and Alt (progress reversely) as well as hours (keypad keys only) work fine. My problem is anything regarding the Shift modifier keys. They don’t work with keypad keys and seem only to work with the alpha numeric keyboard.

What I have tested so far:
Shift+G: works
Shift+Alpha0-9: works (I use them for other input however)
Shift+Keypad0-9: doesn’t work

If you think about the actual keyboard layout it makes sense since they do produce different character output. But this refers to word processing mainly. Also Control+Keypad or Alt+Keypad would not make sense in this way of thinking, but they DO WORK.

My understanding is that you can poll for each imaginable key combination that is possible using the GetKey# methods. Am I wrong or did I find a bug here?

Thank you in advance.

Your keyboard is submitting a different keypress when you use shift+keypad#. On my keyboard, shift+keypad0 is sending insert. Shift+keypad1 is End. Shift+keypad4 is left arrow, etc.

You are right. Oh no, it is that simple. I always thought you had to use the num lock key in order to switch and use the secondary function of the numpad. Is there a way for me to implement it my way without having a special Shift-condition and then polling for KeyCode.End (instead of Keypad1), KeyCode.DownArrow (instead of Keypad2) and so on? Like is there a way to configure your keyboard layout/switch to another layout in Windows that it is not using Shift+Keypad#?

I don’t know how to circumvent it without special case handling (if shift && end, etc).

As a design consideration, however, I’d caution against changing your keyboard configuration away from the default. If users have to alter some setting internal to their OS in order to get your app to work, that will decrease the adoption rate.

As I wrote in my first post this is for debugging and development purposes only. Whether or not this functionality shall be included in the final program and whether I am going to release my program is another question. So if the functionality is going to make it into the program I am probably going to create an UI equivalent.