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 Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      563 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      329 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      547 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      548 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X