Page 1 of 1

How to detect #PB_Key_Minus and #PB_Key_PadComma ?

Posted: Fri Feb 14, 2025 5:58 pm
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?

Re: How to detect #PB_Key_Minus and #PB_Key_PadComma ?

Posted: Fri Feb 14, 2025 7:18 pm
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

Re: How to detect #PB_Key_Minus and #PB_Key_PadComma ?

Posted: Fri Feb 14, 2025 9:59 pm
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?

Re: How to detect #PB_Key_Minus and #PB_Key_PadComma ?

Posted: Fri Feb 14, 2025 10:13 pm
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?

Re: How to detect #PB_Key_Minus and #PB_Key_PadComma ?

Posted: Sat Feb 15, 2025 2:35 am
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

Re: How to detect #PB_Key_Minus and #PB_Key_PadComma ?

Posted: Sat Feb 15, 2025 12:16 pm
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

Re: How to detect #PB_Key_Minus and #PB_Key_PadComma ?

Posted: Sat Feb 15, 2025 4:31 pm
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... ...  ...