How to detect #PB_Key_Minus and #PB_Key_PadComma ?

Just starting out? Need help? Post your questions and find answers here.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

How to detect #PB_Key_Minus and #PB_Key_PadComma ?

Post by Psychophanta »

I am unable to detect '#PB_Key_Minus' neither '#PB_Key_PadComma' keys with the keyboard native library.
Is it an issue from my keyboard or is it a general thing?
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
STARGÅTE
Addict
Addict
Posts: 2259
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: How to detect #PB_Key_Minus and #PB_Key_PadComma ?

Post by STARGÅTE »

The question to me is, what are these keys?

The keys on the pad are named: #PB_Key_Subtract and #PB_Key_Decimal
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: How to detect #PB_Key_Minus and #PB_Key_PadComma ?

Post by Psychophanta »

STARGÅTE wrote: Fri Feb 14, 2025 7:18 pm The question to me is, what are these keys?
Don't you have access to the documentation manual?
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
STARGÅTE
Addict
Addict
Posts: 2259
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: How to detect #PB_Key_Minus and #PB_Key_PadComma ?

Post by STARGÅTE »

Psychophanta wrote: Fri Feb 14, 2025 9:59 pm
STARGÅTE wrote: Fri Feb 14, 2025 7:18 pm The question to me is, what are these keys?
Don't you have access to the documentation manual?
I have, but what am I supposed to read there?
There is no information about the constants' meaning!

On German keyboard, #PB_Key_Minus is mapped to "ß"-key and but #PB_Key_PadComma?
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
BarryG
Addict
Addict
Posts: 4219
Joined: Thu Apr 18, 2019 8:17 am

Re: How to detect #PB_Key_Minus and #PB_Key_PadComma ?

Post by BarryG »

STARGÅTE wrote: Fri Feb 14, 2025 7:18 pmwhat are these keys?
They look like something to do with the numeric keypad. They're listed here -> https://www.purebasic.com/documentation ... ushed.html
Axolotl
Addict
Addict
Posts: 872
Joined: Wed Dec 31, 2008 3:36 pm

Re: How to detect #PB_Key_Minus and #PB_Key_PadComma ?

Post by Axolotl »

I think the keys you are looking for are

Code: Select all

Debug #PB_Shortcut_Subtract 
Debug #PB_Shortcut_Decimal 
test the NUM-Pad Keys with this little helper (borrowed from help Inkey()):

Code: Select all

  If OpenConsole()
    PrintN("Press Escape to exit")
  
    Repeat
      KeyPressed$ = Inkey() 
      rkey = RawKey()  

      If KeyPressed$ <> ""
        
        PrintN("You pressed: " + KeyPressed$)
        PrintN("It has a raw code of: " + Str(rkey)) 

        If rkey = #PB_Shortcut_Subtract 
          PrintN("  Subtract ")
        ElseIf rkey = #PB_Shortcut_Decimal
          PrintN("  Decimal ")   ; only if NUM is active !!! 
        EndIf 
      ElseIf rkey       
        PrintN("You pressed a non ASCII key.")
        PrintN("It has a raw code of: " + Str(rkey))
      Else
        Delay(20) ; Don't eat all the CPU time, we're on a multitask OS
      EndIf    
    Until KeyPressed$ = Chr(27) ; Wait until escape is pressed
  
    CloseConsole()  ; ? missing in the help example 
  EndIf
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: How to detect #PB_Key_Minus and #PB_Key_PadComma ?

Post by Psychophanta »

Thanks to all of you.
What happens is that manual, in the list pointed by BarryG, should remark that the names are for the english keyboards only.

At the moment i solved it with

Code: Select all

ElseIf KeyboardReleased(#PB_Key_Minus) Or KeyboardReleased(#PB_Key_Slash) Or KeyboardReleased(#PB_Key_Subtract):blah blah blah .. ...
ElseIf KeyboardReleased(#PB_Key_PadComma) Or KeyboardReleased(#PB_Key_Decimal) Or KeyboardReleased(#PB_Key_Period):bluh bluh bluh... ...  ...
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Post Reply