bootkeyboard not updating led status (solved)

In my code I'm waiting for the num lock to change status. However it appears that the status lights are never updated. Do I need to do something to update the stats. I'm using NicoHood HID, on a leonardo board. It's connected to a windows 7 computer. The leo detects that the scroll lock is pressed, but never leaves the while loop that waits for the num lock to change.

if ((BootKeyboard.getLeds() & LED_SCROLL_LOCK)){
 
  while ((BootKeyboard.getLeds() & LED_SCROLL_LOCK)){//Exit after scroll look is released
  LastgetLeds =(BootKeyboard.getLeds()& !LED_NUM_LOCK);
  while ((BootKeyboard.getLeds() & !LED_NUM_LOCK)   ==  LastgetLeds){}
 }

You are or’ing certain values with the result of getLeds() to produce a true/false value. You can’t simply put in a negatation to get the opposite result.

For example, say LED_SCROLL_LOCK = 0x10 and LED_NUM_LOCK = 0x20.

If you execute !LED_NUM_LOCK, you get the value 0. What you want is to or the getLeds() with the key of interest and then negate that result to signal is is not pressed.

You want

if ((BootKeyboard.getLeds() & LED_SCROLL_LOCK)){
 
  while ((BootKeyboard.getLeds() & LED_SCROLL_LOCK)){//Exit after scroll look is released
  LastgetLeds =!(BootKeyboard.getLeds()& LED_NUM_LOCK);
  while (!(BootKeyboard.getLeds() & LED_NUM_LOCK)   ==  LastgetLeds){}
 }

Thanks BLH64, I should have know that but forgot. Also for some reason, I needed a delay in the while loop.