# OnKeyDown event to trigger RequestPrint for PowerChart component not working

**URL:** <https://forum.inductiveautomation.com/t/onkeydown-event-to-trigger-requestprint-for-powerchart-component-not-working/107197>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [June 9, 2025, 8:27pm UTC](https://forum.inductiveautomation.com/t/onkeydown-event-to-trigger-requestprint-for-powerchart-component-not-working/107197 "2025-06-09T20:27:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![danny.lazaro](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/danny.lazaro/32/79188_2.png) [@danny.lazaro](https://forum.inductiveautomation.com/u/danny.lazaro)\
**Post date:** [June 9, 2025, 8:27pm UTC](https://forum.inductiveautomation.com/t/onkeydown-event-to-trigger-requestprint-for-powerchart-component-not-working/107197/1 "2025-06-09T20:27:44Z")

</div>

Hi,

I am working with a Power Chart component. I wish there was a sliding Trace I want two things:

- Print the view using component action.
- X Trace to have values at the time of printing. X Trace only shows values when your mouse cursor is hovering over the chart. Can't print using a button because of this.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/5/c59b314f5a7371e51934c0560f1980310dbea655.png)

So, I have configured an onKeyDown event to trigger the RequestPrint action for the Power Chart. This way, whenever you have placed your mouse over the instant you want the X Trace to show values for on the table you can press a key and print the view. I don't think I am doing it right since it isn't working. I have added a script action to set the focus on the Power Chart component (self.focus()) because the onKeyDown event only triggers if it is in focus.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/7/97d02770ed3fe4a14cda4bd1e568c5419d505eef.png)

Thank you in advance for your help!

---

<div class="post-metadata">

**Author:** ![Kevin\_Flener](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@Kevin\_Flener](https://forum.inductiveautomation.com/u/Kevin_Flener)\
**Post date:** [June 9, 2025, 8:33pm UTC](https://forum.inductiveautomation.com/t/onkeydown-event-to-trigger-requestprint-for-powerchart-component-not-working/107197/2 "2025-06-09T20:33:17Z")

</div>

If the onKeyDown event only triggers when the component is in focus, then placing a the self.focus() on the onKeyDown event won't trigger, and it won't gain focus...right?

---

<div class="post-metadata">

**Author:** ![danny.lazaro](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/danny.lazaro/32/79188_2.png) [@danny.lazaro](https://forum.inductiveautomation.com/u/danny.lazaro)\
**Post date:** [June 9, 2025, 8:46pm UTC](https://forum.inductiveautomation.com/t/onkeydown-event-to-trigger-requestprint-for-powerchart-component-not-working/107197/4 "2025-06-09T20:46:37Z")

</div>

You are right I have also tried onStart for the self.focus() script, that will not work either.

---

<div class="post-metadata">

**Author:** ![Ryan\_Deardorff](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan_deardorff/32/63815_2.png) [@Ryan\_Deardorff](https://forum.inductiveautomation.com/u/Ryan_Deardorff)\
**Post date:** [June 9, 2025, 8:50pm UTC](https://forum.inductiveautomation.com/t/onkeydown-event-to-trigger-requestprint-for-powerchart-component-not-working/107197/5 "2025-06-09T20:50:29Z")

</div>

> [@danny.lazaro](#):
>
> I have also tried onStart for the self.focus() script

`onStart` for one component might fire before other components in the view are initialized and attempt to take the focus for themselves. Please vote for my suggestion of an `onLoad` handler that would fire once the entire view is done loading:

> **[Perspective view onLoad event that fires when the view is done loading |...](https://ideas.inductiveautomation.com/ignition-features-and-ideas/p/perspective-view-onload-event-that-fires-when-the-view-is-done-loading)**
>
> This would be the only clean way of ensuring that, for example, an input .focus() would execute at the right time... https://forum.inductiveautomation.

You might find success with a hack that uses a `Timer` to delay the focus request...

---

<div class="post-metadata">

**Author:** ![danny.lazaro](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/danny.lazaro/32/79188_2.png) [@danny.lazaro](https://forum.inductiveautomation.com/u/danny.lazaro)\
**Post date:** [June 9, 2025, 8:58pm UTC](https://forum.inductiveautomation.com/t/onkeydown-event-to-trigger-requestprint-for-powerchart-component-not-working/107197/6 "2025-06-09T20:58:41Z")

</div>

Good idea, I think you are right. I was able to fix this by wrapping the PowerChart on a Container and configuring the events on that container instead of the PowerChart. However, it will only work once, to make it work every time I had to use the onPointerMove event to trigger the self.focus() script.
