Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

IsKeyDown issue

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    IsKeyDown issue

    My indicator BarTimerHybrid rotates the timer around the screen on a key combo (Ctrl + 0 or Ctrl + 1).
    I am trying to update it and have run across an issue.
    If i change the Control modifier to Alt - it doesn't work

    Code:
            public void OnKeyDown(object sender, System.Windows.Input.KeyEventArgs e)// change to eg Alt here it no longer works
        {
                if(Keyboard.Modifiers == ModifierKeys.Control)                  
            {
                if (e.Key == Key.D0|| e.Key == Key.NumPad0 )            
                {
    .....
    and equally this only partially works ( does not recognise NumPad inputs)(I checked that NumLock is on!)

    Code:
            public void OnKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {       
            if(Keyboard.IsKeyDown(Key.LeftAlt))                  
            {          
                    if( Keyboard.IsKeyDown(Key.NumPad0) || Keyboard.IsKeyDown(Key.D0))
                {
    .....
    Any idea why?
    What am I missing?

    #2
    Hello Mindset,

    This would be undocumented custom C# and would be outside of what our support team is able to assist with.

    This thread will remain open for any community members that would like to provide guidance or unsupported code samples.

    You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like a list of affiliate consultants who would be happy to create this script or any others at your request or provide one on one educational services.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Here's the solution - not sure why it's an undocumented feature. I mean it's just some keyboard input after all.

      protected void ChartControl_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
      {
      if(Keyboard.IsKeyDown(Key.LeftCtrl))
      {
      if(Keyboard.IsKeyDown(Key.D0) || Keyboard.IsKeyDown(Key.NumPad0))
      {​
      ....

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by cmoran13, Yesterday, 01:02 PM
      0 responses
      23 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      16 views
      0 likes
      Last Post PaulMohn  
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      160 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      94 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      147 views
      2 likes
      Last Post CaptainJack  
      Working...
      X