https://foro.gambas-es.org/viewtopic.php?f=1&t=4766&p=48929#p48929
-----------------------------------
v3ctor
Miercoles, 24 Junio 2020, 18:34

Re: Como Detectar Si La Tecla Bloq Mayúsculas Esta Activada O No?
-----------------------------------
buenas, en el proyecto photoManager de pilvalaquarus

encontré este código sencillo y efectivo!!

[code linenumbers=false syntax=gambas]Public Sub CheckCapsLock()                                                     'To check the Caps Lock state

     Dim sState As String                                                      'To store the 'Shell' output
     Dim siCap As Short                                                        'To store the 'Value' of Caps Lock state

     Shell "xset q | grep 'LED mask'" To sState                                'Shell command. Result is similar to: - 'auto repeat:  on    key click percent:  0    LED mask:  00000003'

     siCap = Right(Bin(Right(Trim(sState), 1)), 1)                             'Get the last binary value, see alternative code below

     If siCap Then                                                             'If siCap is not 0 then..
          LabelCaps.text = ("Caps Lock is ON")                                 'Add a message to the Form indicating the Caps Lock is on
     Else                                                                      'siCap must be 0
          LabelCaps.text = ""                                                  'Clear the Caps Lock message
     Endif

End[/code]


