Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Keypresses

  1. #1

    Keypresses

    Hi I searched this on google but all I found was ascii codes. What I would need is check if for example the up arrow button is pressed. (I don't think that button has an ascii code or does it?)

  2. #2
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,108
    Blog Entries
    25
    Hi there is a way to capture key presses using just the system function units in FPC or Delphi, but you may find it easier and better to use something like SDL or DirectX where you have better control over detecting when different keys are pressed and/or released. JEDI-SDL and maybe DelphiX (only if you are using Delphi though!) could be a good starter library for you...?
    Jason McMillen
    Pascal Game Development
    Co-Founder





  3. #3
    PGDCE Developer Carver413's Avatar
    Join Date
    Jun 2010
    Location
    Spokane,WA,Usa
    Posts
    206
    what would life be like without Google
    http://delphi.about.com/od/objectpascalide/l/blvkc.htm

  4. #4
    Thanks altough I never used those compilers before I will really look at how they work if I get back but now I'm at home my comp is at the student-hostel and I don't want to fill mom's comp with pascal stuff I use free pascal so those Delphi functions won't help me out but thanks anyways.

  5. #5
    PGD Staff / News Reporter phibermon's Avatar
    Join Date
    Sep 2009
    Location
    England
    Posts
    524
    I use dogpile (http://www.dogpile.com/)

    It's combination of search results from the various big names is quite useful when searching the more commonly spammed topics
    When the moon hits your eye like a big pizza pie - that's an extinction level impact event.

  6. #6
    PGDCE Developer Carver413's Avatar
    Join Date
    Jun 2010
    Location
    Spokane,WA,Usa
    Posts
    206
    Quote Originally Posted by asdfarkangel View Post
    Thanks although I never used those compilers before I will really look at how they work if I get back but now I'm at home my comp is at the student-hostel and I don't want to fill mom's comp with pascal stuff I use free pascal so those Delphi functions won't help me out but thanks anyways.
    those are not delphi functions they are const. and you can use that chart to define them in free pascal

    procedure TForm1.Memo1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    const
    VK_UP = $26;
    begin
    if key = VK_UP then LoggerUnit.Logger.Msg('Up Key');
    end;

    this works just fine in lazarus, minus the LoggerUnit which is my own code. those const are probable defined some where in lazarus but I don't have a clue where. in delphi I think that they are part of the win unit. just because you are using free pascal you shouldn't discard everything delphi. most code can be made to work on lazarus and there is a wealth of information out there for delphi. even old delphi books can be of use to you

  7. #7
    Quote Originally Posted by Carver413 View Post
    Code:
    const
        VK_UP = $26;
    begin
      if key = VK_UP then ...
    Tip: You can add Lcltype in uses clause of your Lazarus project, all virtual keycodes such as VK_UP, VK_ESCAPE are there in cross-platform way.

  8. #8
    PGDCE Developer Carver413's Avatar
    Join Date
    Jun 2010
    Location
    Spokane,WA,Usa
    Posts
    206
    Quote Originally Posted by User137 View Post
    Tip: You can add Lcltype in uses clause of your Lazarus project, all virtual keycodes such as VK_UP, VK_ESCAPE are there in cross-platform way.
    Thanks for that, I knew it was probable in there somewhere. one can get lost digging through all that code and still not find what your looking for.

  9. #9
    Oh well thanks all of you. Writing a Biology test at university today but I will experiment with these functions a little when I'm done with that. Interesting when I learn programming, instead of memorizing syntaxes and procedure/function names and following methods, I just start writing something to experiment with it. I look it up in google if I need a func. or proc. see the syntaxes and correct methodical errors and I learn a lot easier this way. I can not imagine for example that I could have learnt the useage of binary files by just reading the book, and then I would have been able to use it correctly instantly. Altough for my programs written this way in the end I often find out there was a lot lot more easier way. Well often means almost always xD

  10. #10
    vk_ constants are also in the WINDOWS unit. If you are using SDL, there are the SDLK_ constants which are identical in value to the vk_ ones.
    The accessibility of a website from time to time must be refreshed with the blood of designers and owners. It is its natural manure

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Comodo SSL