Home › forums › Using CanvasJS › Useing CanvasJS with mousewheel
Tagged: keyboard shortcuts, zoom
This topic contains 4 replies, has 2 voices, and was last updated by mihaela 2 months, 1 week ago.
Do you have any examples or recommendations for using CanvasJS charts (in particular zoom in) from mouse wheel?
Same question for keyboard keys interaction with the plots.
You can achieve this by attaching wheel event to the chart as shown in this JSFiddle.
Great example, exactly as needed, thanks!
Is there an example you can provide for attaching keyboard events? We would like to use keyboard keys as shortcuts for certain operations like zoom in/out or pan left right.
Thanks again for your excellent support.
Similar to how wheel event was attached to achieve zooming the chart with mouse-wheel, you need to attach keydown event to achieve on pressing any key in the keyboard. Please take a look at this JSFiddle. Please refer this stackoverflow thread for more information on key-codes.
Note: As JSFiddle has multiple panels (like HTML, JS, Result, etc), make sure you click somewhere in the result panel and then on top of chart once so that keyboard events are captured by chart.
Thanks for the example, it is working great.
You must be logged in to reply to this topic.