CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

[How To] Get the pressed key

by Alexander Bulei » 16 Oct 2013 16:43

To get the pressed key, you should follow the next steps:

  • Add new BrowserParam to event:

    Example:

    delphi code
    procedure TIWForm1.IWAppFormCreate(Sender: TObject);
    begin
    with IWCGJQEdit1.JQEvents.OnKeyPress.BrowserParams.Add do
    begin
    ServerName:= 'keypressed';
    BrowserScript:= 'e.keyCode || e.which';
    end;
    end;


    Note: You can add the new BrowserParam in design-time or run-time.

  • On KeyPress event, get the passed parameter:

    Example:

    delphi code
    procedure TIWForm1.IWCGJQEdit1JQEventsKeyPress(Sender: TObject; AParams: TStringList);
    begin
    WebApplication.ShowMessage(AParams.Values['keypressed']);
    end;

If you need to run the event in a certain key, you should use the Condition property.
This will prevent that on each key pressed, will call the event on server.

Example for "Enter":

delphi code
procedure TIWForm1.IWAppFormCreate(Sender: TObject);
begin
with IWCGJQEdit1.JQEvents.OnKeyPress do
begin
Condition:= '((e.keyCode==13) || (e.which==13))'
end;
end;


Best Regards.
Group: Developers | Support Team

  • info [at] cgdevtools.com - General information
  • sales [at] cgdevtools.com - Sales department
  • support [at] cgdevtools.com - Product and Technical Support
User avatar
Alexander Bulei
Site Admin
 
Posts: 3635
Joined: 15 May 2012 08:52
Location: Mealhada, Portugal

by fateh78 » 27 Apr 2017 12:05

How to get ShiftState (Ctrl/Alt/Shift) ??
fateh78
 
Posts: 85
Joined: 16 Mar 2017 21:45

by Alexander Bulei » 02 May 2017 09:41

Hi fateh78,

Use the same way (browserParameters) to send the states:

Code: Select all
BrowserScript:= 'e.shiftKey';
BrowserScript:= 'e.altKey';
BrowserScript:= 'e.ctrlKey';


Note: For each key estate, you must create BrowserParameter.

Best Regards.
Group: Developers | Support Team

  • info [at] cgdevtools.com - General information
  • sales [at] cgdevtools.com - Sales department
  • support [at] cgdevtools.com - Product and Technical Support
User avatar
Alexander Bulei
Site Admin
 
Posts: 3635
Joined: 15 May 2012 08:52
Location: Mealhada, Portugal


Return to JQEdit

cron

Who is online

Users browsing this forum: No registered users and 1 guest

Contact Us.