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 Mindset, 04-21-2026, 06:46 AM
      0 responses
      63 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      92 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      48 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      106 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      63 views
      0 likes
      Last Post PaulMohn  
      Working...
      X