Calls to TerminalInfoInteger(TERMINAL_KEYSTATE_XXX) always return 0 for undocked charts.

 
void OnChartEvent(const int id,const long& lparam,const double& dparam,const string& sparam)
   {
      if (id == CHARTEVENT_KEYDOWN)
      {
         Print(TerminalInfoInteger(TERMINAL_KEYSTATE_CONTROL));
      }
   }

On a key down event, it will print the states of the Ctrl key. It works correctly when the chart is docked, and prints -128 when Ctrl key is pressed. But when I undock the chart and press Ctrl key it always prints 0.

Does anyone know how to solve this?