Page 1 of 1

Holding down (typematic repeat)

PostPosted: Thu May 10, 2012 7:41 pm
by Tranquil.Suit
Hello,

When you normally press and hold down a key (example z) in Notepad (or even in this posting box on the forums), it will print one ''z' immediately, then after a fraction of a second it will continue printing 'z's (one by one, at a very quick rate).

Now I was expecting the same thing to happen with the code below, when I would press and hold 'b' or 'c'. Instead all three hotkeys (a, b, c), did the same thing (as I pressed and held): Print one letter immediately (in Notepad), and that's it. Repeatedly tapping worked fine (printed a letter with every tap).

Is there any way to do it (what I originally expected)? Am I missing something obvious?


Code: Select all
<Command AutoExec>
<Label R0 Local SendWin R0>
<Run c:\WINDOWS\system32\notepad.exe>
<RenameTargetWin R0>

//1 normal key
<Hotkey a>
<sendLabel R0>
  <Key a>

//2 combine down up
<Hotkey b>
<sendLabel R0>
  <KeyDown b>

<HotkeyUp b>
<sendLabel R0>
  <KeyUp b>

//3 movement hotkey
<MovementHotkey c>
<sendLabel R0>
  <Key c>




Thanks in advance.

Re: Holding down (typematic repeat)

PostPosted: Fri May 11, 2012 1:56 am
by HotkeyNet
The feature you describe is called "typematic repeat." That's what IBM named it in the 1960s when they implemented it for the first time on Selectric typewriters. "Matic" sounded cool and futuristic in those days. Cadillacs used to come with "Hydramatic" transmissions.

Usually people ask here about typematic repeat because they imagine it's used for movement in games. This is seldom the case because the initial delay makes typematic repeat inappropriate for movement.

The reason your script doesn't do what you expect is because <Key>, <KeyUp>, and <KeyDown> perform an action once. For example, <KeyDown> sends a single key press. <Key> sends a single key press followed by a single key release.

If you want to send repeated key presses, you need to execute <KeyDown> over and over. There's a sample script that shows how to do this (the one I wrote) in the following thread:

viewtopic.php?f=37&t=1883&p=12908&hilit=typematic#p12908