Skip to content

Commit f0718d7

Browse files
committed
Change keyboard simulation
1 parent 98477f1 commit f0718d7

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

VVDocumenter-Xcode/VVDocumenterManager.m

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,9 @@ - (void) textStorageDidChange:(NSNotification *)noti {
149149
//Cmd+delete Delete current line
150150
[kes sendKeyCode:kVK_Delete withModifierCommand:YES alt:NO shift:NO control:NO];
151151
//if (shouldReplace) [textView setSelectedRange:resultToDocument.range];
152-
//Cmd+V, paste
153-
[kes sendKeyCode:kVK_ANSI_V withModifierCommand:YES alt:NO shift:NO control:NO];
152+
//Cmd+V, paste (If it is Dvorak layout, use '.', which is corresponding the key 'V' in a QWERTY layout)
153+
NSInteger kKeyVCode = [[VVDocumenterSetting defaultSetting] useDvorakLayout] ? kVK_ANSI_Period : kVK_ANSI_V;
154+
[kes sendKeyCode:kKeyVCode withModifierCommand:YES alt:NO shift:NO control:NO];
154155

155156
//The key down is just a defined finish signal by me. When we receive this key, we know operation above is finished.
156157
[kes sendKeyCode:kVK_F20];
@@ -176,7 +177,7 @@ - (void) textStorageDidChange:(NSNotification *)noti {
176177

177178
//Invalidate the finish signal, in case you set it to do some other thing.
178179
return nil;
179-
} else if ([incomingEvent type] == NSKeyDown && [incomingEvent keyCode] == kVK_ANSI_V && shouldReplace == YES) {
180+
} else if ([incomingEvent type] == NSKeyDown && [incomingEvent keyCode] == kKeyVCode && shouldReplace == YES) {
180181
//Select input line and the define code block.
181182
NSRange r = [textView textResultUntilNextString:@";"].range;
182183

0 commit comments

Comments
 (0)