carlos-montiers / enhancedbatch

Enhances your windows command prompt https://www.enhancedbatch.com
Other
5 stars 1 forks source link

kbhit and chhit return #35

Closed carlos-montiers closed 4 years ago

carlos-montiers commented 4 years ago

Hello. I'm thinking that KBHIT in the getter and caller form should return code 0 if no key was present, and CHHIT should return empty string if no key was present.

Because we can have negatives code when extended keys are used, 0 for code and empty string for character are more significant to represent "none".

I understand CHHIT return -1 for allow get the code of the NULL character, but I think that is not a common key for press, even CTRL+A produces 1, thus how someone can press the NULL character?. Thus I think is better replace the use of -1

adoxa commented 4 years ago

You wanted to replace KBHIT/GETKB with virtual key names, so no key would become VK_NONE. Do you no longer want to do that?

^@ (aka Ctrl+2) is the null character, but we currently assume it to be an extended key, so it just waits for another character, anyway. Besides which, it generates an empty string, so won't work, anyway. An empty string is a little harder to test, since it undefines a variable or needs quoting in an IF.

carlos-montiers commented 4 years ago

You wanted to replace KBHIT/GETKB with virtual key names, so no key would become VK_NONE. Do you no longer want to do that?

I already want that.

^@ (aka Ctrl+2) is the null character

Oh, I not know that.

An empty string is a little harder to test, since it undefines a variable or needs quoting in an IF.

Thus I prefer keep using the -1 for CHHIT and KBHIT