We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Using the keyboard to page through the page HTMLUIControl contents

Hi,

Is it possible to use the keyboard to page up and down through a page using the HTMLUIControl?

I know that it ispossible to use the mouse to scroll through, but so far I hav been unable to find a way to achieve this through the keyboard. Sorry if I've missed something obvious.

Andy

3 Replies

JP Jagadeesan Pichaimuthu Syncfusion Team June 12, 2019 12:37 PM UTC

Hi Andy, 
 
Thanks for using Syncfusion product. 
 
We have checked your requirement, but currently the HTMLUI control not have support for the page up and page down keys. You can refer the following documentation for the supported key operations in this control, 
 
 
But you can able to achieve your requirement by customizing the KeyUp event of the control. In HTMLUI control provides support to scroll by using the ScrollToElement(which scrolls to the particular element) and ScrollToRectangle(which is used to scroll to specific location). By using these methods you can able to perform the page up and page down operations, please refer the below code snippet and sample. 
 
this.htmluiControl1.KeyUp += HtmluiControl1_KeyUp; 
 
private void HtmluiControl1_KeyUp(object sender, KeyEventArgs e) 
{ 
    if(e.KeyData == Keys.PageDown) 
    { 
        this.ScrollToEnd(); 
    } 
    else if(e.KeyData == Keys.PageUp) 
    { 
        this.ScrollToTop(); 
    }             
} 
 
 
private void ScrollToTop() 
{ 
    IHTMLElement elem = this.htmluiControl1.Document.RenderRoot; 
    this.htmluiControl1.ScrollToElement(this.htmluiControl1.Document.RenderRoot); 
} 
 
private void ScrollToEnd() 
{ 
    IHTMLElement elem = this.htmluiControl1.Document.RenderRoot; 
    Point lastPoint = new Point(0, (elem.Location.Y + elem.Size.Height)); 
    Rectangle rect = new Rectangle(new Point(10, lastPoint.Y - 10), new Size(10, 10)); 
    this.htmluiControl1.ScrollToRectangle(rect, this.htmluiControl1.Document); 
} 
 
 
You can refer the below UG document for your reference. 
 
Let us know whether this helps also if you need any further assistance on this. 
 
Regards, 
Jagadeesan 



AF Andy Foster June 15, 2019 06:34 AM UTC

Thank you. With your suggestions and a couple of API calls I have been able to achieve page and line scrolling.

Appreciate your help.

Andy


JP Jagadeesan Pichaimuthu Syncfusion Team June 17, 2019 09:00 AM UTC

Hi Andy, 
 
Thanks for your update. 
 
We are glad to know that the provided solution worked at your end. Please let us know if you have any further queries on this. We are happy to help you. 
 
Regards, 
Jagadeesan 


Loader.
Live Chat Icon For mobile
Up arrow icon