'How to implement CMD + C and CMD + V in pygame
I have working example which copies user input running at Windows
text=""
if event.key == pygame.K_c and pygame.key.get_mods() & pygame.KMOD_CTRL and not pygame.key.get_mods() & pygame.KMOD_ALT:
print("pressed CTRL-C as an event")
pyperclip.copy(text)
but not at mac, I could not find any string representing Mac "command" key in documentation https://www.pygame.org/docs/ref/key.html and thus have hard time implementing copying there. Does anyone know how to solve this?
Solution 1:[1]
pygame.KMOD_META represents the command key on macOS. So, your code would look like:
if event.key == pygame.K_c and pygame.key.get_mods() & pygame.KMOD_META and not pygame.key.get_mods() & pygame.KMOD_ALT:
print("pressed CMD-C as an event")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | AlarmClockMan |
