Keyboard Shortcuts Every Programmer Should Know

18 Most Useful Keyboard Shortcuts For Programmers



What is GEEK

Buddha Community

Keyboard Shortcuts Every Programmer Should Know
Houston  Sipes

Houston Sipes


10 Mac Keyboard Shortcuts Every New Programmer Needs to Know

Before I learned to write code, I wrote blog posts and marketing copy for businesses in the hospitality industry. Since my work was remote and on a freelance basis, I didn’t have co-workers, but house guests and strangers in coffee shops often commented on my lighting fast typing speed. Also, that I’m a very loud typer — you can rest assured that there is a lot of force behind these words!

But when I started my programming journey, the new-to-me syntax and constant changes needed to make my code work had me hunting and pecking at the keyboard like my 93-year old grandma.

Not only was the constant search for curly brackets a source of utter frustration but just watching more experienced developers work made me feel overwhelmed. Changing variable names in multiple locations all at once? Commenting out large sections of code in a single blow? It was all so fast! Were they developers _and _wizards? Maybe…

Here’s the truth, experienced developers (i.e. magicians) have two things going for them that you, as a programming newcomer, don’t:

  1. They are experienced and have written million trillion times more code then you have. Give yourself a break.
  2. They know keyboard shortcuts that save loads of time and prevent them from breaking their flow by reaching for their mouse or trackpad.

Why New Programmers Should Learn Keyboard Shortcuts

Learning a programming language is already mind-boggling, and often new developers are also being introduced to additional new-to-you technologies, like text editors, Git, GitHub, the Command Line, and even using a Mac, all while typing out “Hello World” for the first time.

With so much new information, it’s understandable that many new programmers don’t prioritize learning keyboard shortcuts. However, investing a little time upfront to master a few simple commands will pay off in a big way.

As you integrate these keyboard shortcuts into your repertoire you will increase your productivity, become more comfortable writing and debugging code, and likely experience a big boost to your confidence as your fellow first-time coders ask you how you learned such sorcery!

10 Mac Keyboard Shortcuts for New Programmers

While there are many keyboard shortcuts for your Mac, here are ten commands that new programmers can start using ASAP to make writing code feel more natural.

#programming #coding #mac #keyboard-shortcuts #productivity

Keyboard: Take Full Control Of Keyboard With This Small Python Library

Hook and simulate global keyboard events on Windows and Linux.

Take full control of your keyboard with this small Python library. Hook global events, register hotkeys, simulate key presses and much more.


  • Global event hook on all keyboards (captures keys regardless of focus).
  • Listen and send keyboard events.
  • Works with Windows and Linux (requires sudo), with experimental OS X support (thanks @glitchassassin!).
  • Pure Python, no C modules to be compiled.
  • Zero dependencies. Trivial to install and deploy, just copy the files.
  • Python 2 and 3.
  • Complex hotkey support (e.g. ctrl+shift+m, ctrl+space) with controllable timeout.
  • Includes high level API (e.g. record and play, add_abbreviation).
  • Maps keys as they actually are in your layout, with full internationalization support (e.g. Ctrl+ç).
  • Events automatically captured in separate thread, doesn't block main program.
  • Tested and documented.
  • Doesn't break accented dead keys (I'm looking at you, pyHook).
  • Mouse support available via project mouse (pip install mouse).


Install the PyPI package:

pip install keyboard

or clone the repository (no installation required, source files are sufficient):

git clone

or download and extract the zip into your project folder.

Then check the API docs below to see what features are available.


Use as library:

import keyboard

keyboard.press_and_release('shift+s, space')

keyboard.write('The quick brown fox jumps over the lazy dog.')

keyboard.add_hotkey('ctrl+shift+a', print, args=('triggered', 'hotkey'))

# Press PAGE UP then PAGE DOWN to type "foobar".
keyboard.add_hotkey('page up, page down', lambda: keyboard.write('foobar'))

# Blocks until you press esc.

# Record events until 'esc' is pressed.
recorded = keyboard.record(until='esc')
# Then replay back at three times the speed., speed_factor=3)

# Type @@ then press space to replace with abbreviation.
keyboard.add_abbreviation('@@', '')

# Block forever, like `while True`.

Use as standalone module:

# Save JSON events to a file until interrupted:
python -m keyboard > events.txt

cat events.txt
# {"event_type": "down", "scan_code": 25, "name": "p", "time": 1622447562.2994788, "is_keypad": false}
# {"event_type": "up", "scan_code": 25, "name": "p", "time": 1622447562.431007, "is_keypad": false}
# ...

# Replay events
python -m keyboard < events.txt

Known limitations:

  • Events generated under Windows don't report device id (event.device == None). #21
  • Media keys on Linux may appear nameless (scan-code only) or not at all. #20
  • Key suppression/blocking only available on Windows. #22
  • To avoid depending on X, the Linux parts reads raw device files (/dev/input/input*) but this requires root.
  • Other applications, such as some games, may register hooks that swallow all key events. In this case keyboard will be unable to report events.
  • This program makes no attempt to hide itself, so don't use it for keyloggers or online gaming bots. Be responsible.
  • SSH connections forward only the text typed, not keyboard events. Therefore if you connect to a server or Raspberry PI that is running keyboard via SSH, the server will not detect your key events.

Common patterns and mistakes

Preventing the program from closing

import keyboard
keyboard.add_hotkey('space', lambda: print('space was pressed!'))
# If the program finishes, the hotkey is not in effect anymore.

# Don't do this! This will use 100% of your CPU.
#while True: pass

# Use this instead

# or this
import time
while True:

Waiting for a key press one time

import keyboard

# Don't do this! This will use 100% of your CPU until you press the key.
#while not keyboard.is_pressed('space'):
#    continue
#print('space was pressed, continuing...')

# Do this instead
print('space was pressed, continuing...')

Repeatedly waiting for a key press

import keyboard

# Don't do this!
#while True:
#    if keyboard.is_pressed('space'):
#        print('space was pressed!')
# This will use 100% of your CPU and print the message many times.

# Do this instead
while True:
    print('space was pressed! Waiting on it again...')

# or this
keyboard.add_hotkey('space', lambda: print('space was pressed!'))

Invoking code when an event happens

import keyboard

# Don't do this! This will call `print('space')` immediately then fail when the key is actually pressed.
#keyboard.add_hotkey('space', print('space was pressed'))

# Do this instead
keyboard.add_hotkey('space', lambda: print('space was pressed'))

# or this
def on_space():
    print('space was pressed')
keyboard.add_hotkey('space', on_space)

# or this
while True:
    # Wait for the next event.
    event = keyboard.read_event()
    if event.event_type == keyboard.KEY_DOWN and == 'space':
        print('space was pressed')

'Press any key to continue'

# Don't do this! The `keyboard` module is meant for global events, even when your program is not in focus.
#import keyboard
#print('Press any key to continue...')

# Do this instead
input('Press enter to continue...')

# Or one of the suggestions from here


Table of Contents


= 'down'


= 'up'

class keyboard.KeyboardEvent







KeyboardEvent.to_json(self, ensure_ascii=False)



= {'alt', 'alt gr', 'ctrl', 'left alt', 'left ctrl', 'left shift', 'left windows', 'right alt', 'right ctrl', 'right shift', 'right windows', 'shift', 'windows'}


= {'alt', 'ctrl', 'shift', 'windows'}


= '0.13.5'



Returns True if key is a scan code or name of a modifier key.

keyboard.key_to_scan_codes(key, error_if_missing=True)


Returns a list of scan codes associated with this key (name or scan code).



Parses a user-provided hotkey into nested tuples representing the parsed structure, with the bottom values being lists of scan codes. Also accepts raw scan codes, which are then wrapped in the required number of nestings.


parse_hotkey("alt+shift+a, alt+b, c")
#    Keys:    ^~^ ^~~~^ ^  ^~^ ^  ^
#    Steps:   ^~~~~~~~~~^  ^~~~^  ^

# ((alt_codes, shift_codes, a_codes), (alt_codes, b_codes), (c_codes,))

keyboard.send(hotkey, do_press=True, do_release=True)


Sends OS events that perform the given hotkey hotkey.

  • hotkey can be either a scan code (e.g. 57 for space), single key (e.g. 'space') or multi-key, multi-step hotkey (e.g. 'alt+F4, enter').
  • do_press if true then press events are sent. Defaults to True.
  • do_release if true then release events are sent. Defaults to True.

send('alt+F4, enter')

Note: keys are released in the opposite order they were pressed.


Presses and holds down a hotkey (see send).



Releases a hotkey (see send).



Returns True if the key is pressed.

is_pressed(57) #-> True
is_pressed('space') #-> True
is_pressed('ctrl+space') #-> True

keyboard.call_later(fn, args=(), delay=0.001)


Calls the provided function in a new thread after waiting some time. Useful for giving the system some time to process an event, without blocking the current execution flow.

keyboard.hook(callback, suppress=False, on_remove=<lambda>)


Installs a global listener on all available keyboards, invoking callback each time a key is pressed or released.

The event passed to the callback is of type keyboard.KeyboardEvent, with the following attributes:

  • name: an Unicode representation of the character (e.g. "&") or description (e.g. "space"). The name is always lower-case.
  • scan_code: number representing the physical key, e.g. 55.
  • time: timestamp of the time the event occurred, with as much precision as given by the OS.

Returns the given callback for easier development.

keyboard.on_press(callback, suppress=False)


Invokes callback for every KEY_DOWN event. For details see hook.

keyboard.on_release(callback, suppress=False)


Invokes callback for every KEY_UP event. For details see hook.

keyboard.hook_key(key, callback, suppress=False)


Hooks key up and key down events for a single key. Returns the event handler created. To remove a hooked key use unhook_key(key) or unhook_key(handler).

Note: this function shares state with hotkeys, so clear_all_hotkeys affects it as well.

keyboard.on_press_key(key, callback, suppress=False)


Invokes callback for KEY_DOWN event related to the given key. For details see hook.

keyboard.on_release_key(key, callback, suppress=False)


Invokes callback for KEY_UP event related to the given key. For details see hook.



Removes a previously added hook, either by callback or by the return value of hook.



Removes all keyboard hooks in use, including hotkeys, abbreviations, word listeners, recorders and waits.



Suppresses all key events of the given key, regardless of modifiers.

keyboard.remap_key(src, dst)


Whenever the key src is pressed or released, regardless of modifiers, press or release the hotkey dst instead.



Parses a user-provided hotkey. Differently from parse_hotkey, instead of each step being a list of the different scan codes for each key, each step is a list of all possible combinations of those scan codes.

keyboard.add_hotkey(hotkey, callback, args=(), suppress=False, timeout=1, trigger_on_release=False)


Invokes a callback every time a hotkey is pressed. The hotkey must be in the format ctrl+shift+a, s. This would trigger when the user holds ctrl, shift and "a" at once, releases, and then presses "s". To represent literal commas, pluses, and spaces, use their names ('comma', 'plus', 'space').

  • args is an optional list of arguments to passed to the callback during each invocation.
  • suppress defines if successful triggers should block the keys from being sent to other programs.
  • timeout is the amount of seconds allowed to pass between key presses.
  • trigger_on_release if true, the callback is invoked on key release instead of key press.

The event handler function is returned. To remove a hotkey call remove_hotkey(hotkey) or remove_hotkey(handler). before the hotkey state is reset.

Note: hotkeys are activated when the last key is pressed, not released. Note: the callback is executed in a separate thread, asynchronously. For an example of how to use a callback synchronously, see wait.


# Different but equivalent ways to listen for a spacebar key press.
add_hotkey(' ', print, args=['space was pressed'])
add_hotkey('space', print, args=['space was pressed'])
add_hotkey('Space', print, args=['space was pressed'])
# Here 57 represents the keyboard code for spacebar; so you will be
# pressing 'spacebar', not '57' to activate the print function.
add_hotkey(57, print, args=['space was pressed'])

add_hotkey('ctrl+q', quit)
add_hotkey('ctrl+alt+enter, space', some_callback)



Removes a previously hooked hotkey. Must be called with the value returned by add_hotkey.



Removes all keyboard hotkeys in use, including abbreviations, word listeners, recorders and waits.

keyboard.remap_hotkey(src, dst, suppress=True, trigger_on_release=False)


Whenever the hotkey src is pressed, suppress it and send dst instead.


remap('alt+w', 'ctrl+up')



Builds a list of all currently pressed scan codes, releases them and returns the list. Pairs well with restore_state and restore_modifiers.



Given a list of scan_codes ensures these keys, and only these keys, are pressed. Pairs well with stash_state, alternative to restore_modifiers.



Like restore_state, but only restores modifier keys.

keyboard.write(text, delay=0, restore_state_after=True, exact=None)


Sends artificial keyboard events to the OS, simulating the typing of a given text. Characters not available on the keyboard are typed as explicit unicode characters using OS-specific functionality, such as alt+codepoint.

To ensure text integrity, all currently pressed keys are released before the text is typed, and modifiers are restored afterwards.

  • delay is the number of seconds to wait between keypresses, defaults to no delay.
  • restore_state_after can be used to restore the state of pressed keys after the text is typed, i.e. presses the keys that were released at the beginning. Defaults to True.
  • exact forces typing all characters as explicit unicode (e.g. alt+codepoint or special events). If None, uses platform-specific suggested value.

keyboard.wait(hotkey=None, suppress=False, trigger_on_release=False)


Blocks the program execution until the given hotkey is pressed or, if given no parameters, blocks forever.



Returns a string representation of hotkey from the given key names, or the currently pressed keys if not given. This function:

  • normalizes names;
  • removes "left" and "right" prefixes;
  • replaces the "+" key name with "plus" to avoid ambiguity;
  • puts modifier keys first, in a standardized order;
  • sort remaining keys;
  • finally, joins everything with "+".


get_hotkey_name(['+', 'left ctrl', 'shift'])
# "ctrl+shift+plus"



Blocks until a keyboard event happens, then returns that event.



Blocks until a keyboard event happens, then returns that event's name or, if missing, its scan code.



Similar to read_key(), but blocks until the user presses and releases a hotkey (or single key), then returns a string representing the hotkey pressed.


# "ctrl+shift+p"

keyboard.get_typed_strings(events, allow_backspace=True)


Given a sequence of events, tries to deduce what strings were typed. Strings are separated when a non-textual key is pressed (such as tab or enter). Characters are converted to uppercase according to shift and capslock status. If allow_backspace is True, backspaces remove the last character typed.

This function is a generator, so you can pass an infinite stream of events and convert them to strings in real time.

Note this functions is merely an heuristic. Windows for example keeps per- process keyboard state such as keyboard layout, and this information is not available for our hooks.

get_type_strings(record()) #-> ['This is what', 'I recorded', '']



Starts recording all keyboard events into a global variable, or the given queue if any. Returns the queue of events and the hooked function.

Use stop_recording() or unhook(hooked_function) to stop.



Stops the global recording of events and returns a list of the events captured.

keyboard.record(until='escape', suppress=False, trigger_on_release=False)


Records all keyboard events from all keyboards until the user presses the given hotkey. Then returns the list of events recorded, of type keyboard.KeyboardEvent. Pairs well with play(events).

Note: this is a blocking function. Note: for more details on the keyboard hook and events see hook., speed_factor=1.0)


Plays a sequence of recorded events, maintaining the relative time intervals. If speed_factor is <= 0 then the actions are replayed as fast as the OS allows. Pairs well with record().

Note: the current keyboard state is cleared at the beginning and restored at the end of the function.

keyboard.add_word_listener(word, callback, triggers=['space'], match_suffix=False, timeout=2)


Invokes a callback every time a sequence of characters is typed (e.g. 'pet') and followed by a trigger key (e.g. space). Modifiers (e.g. alt, ctrl, shift) are ignored.

  • word the typed text to be matched. E.g. 'pet'.
  • callback is an argument-less function to be invoked each time the word is typed.
  • triggers is the list of keys that will cause a match to be checked. If the user presses some key that is not a character (len>1) and not in triggers, the characters so far will be discarded. By default the trigger is only space.
  • match_suffix defines if endings of words should also be checked instead of only whole words. E.g. if true, typing 'carpet'+space will trigger the listener for 'pet'. Defaults to false, only whole words are checked.
  • timeout is the maximum number of seconds between typed characters before the current word is discarded. Defaults to 2 seconds.

Returns the event handler created. To remove a word listener use remove_word_listener(word) or remove_word_listener(handler).

Note: all actions are performed on key down. Key up events are ignored. Note: word matches are case sensitive.



Removes a previously registered word listener. Accepts either the word used during registration (exact string) or the event handler returned by the add_word_listener or add_abbreviation functions.

keyboard.add_abbreviation(source_text, replacement_text, match_suffix=False, timeout=2)


Registers a hotkey that replaces one typed text with another. For example

add_abbreviation('tm', u'™')

Replaces every "tm" followed by a space with a ™ symbol (and no space). The replacement is done by sending backspace events.

  • match_suffix defines if endings of words should also be checked instead of only whole words. E.g. if true, typing 'carpet'+space will trigger the listener for 'pet'. Defaults to false, only whole words are checked.
  • timeout is the maximum number of seconds between typed characters before the current word is discarded. Defaults to 2 seconds.

For more details see add_word_listener.



Given a key name (e.g. "LEFT CONTROL"), clean up the string and convert to the canonical representation (e.g. "left ctrl") if one is known.

Author: boppreh
Source Code:
License: MIT License

#python #keyboard 

Brandon  Adams

Brandon Adams


10 Things Beginner Programmers Need to Know

Are you new to coding? Here are some tips and tricks for beginner programmers. Learn the importance of a strong computer science foundation for a software developer with this tutorial. Happy coding!

Need some new tech gadgets or a new charger? Buy from my Amazon Storefront

Check out my podcast The Programmer Toolbox. If you leave us a written review on Apple Podcasts, we’ll send you a free The Programmer Sticker. Just send us your mailing address at and we’ll send it right out.

Also check out…
Make a Google Action
What is a Framework?
What is a JSON Object?
What is an API?
What are API Keys?
Using APIs with Postman

Check out my courses on LinkedIn Learning!

Sign up for LinkedIn Learning!

Support me on Patreon!

Check out my Python Basics course on Highbrow!

Check out behind-the-scenes and more tech tips on my Instagram!

Free HACKATHON MODE playlist:

Stitch Fix Invite Code:
FabFitFun Invite Code:
Uber Invite Code: kathrynh1277ue
Postmates Invite Code: 7373F
SoulCycle Invite Code:
Rent The Runway:

Want to BINGE?? Check out these playlists…

Quick Code Tutorials:

Command Line:

30 Days of Code:

Intermediate Web Dev Tutorials:

GitHub |

Twitter |

LinkedIn |

#blondiebytes #programmers #beginner programmers #things beginner programmers need to know

Brain  Crist

Brain Crist


Top 9 Keyboard Shortcuts in VSCode for Data Scientists


As a data scientist, you might find yourself spending a lot of time on your computer and keyboard. If the construction worker has his power tool, data scientists have their keyboard as their to-go tool. If you can find a way to use your tool more efficiently, you will save yourself a lot of time. That is why I am a big fan of keyboard shortcuts.

If you don’t use keyboard shortcuts frequently, it is time to switch it up. It might take a little bit of time to master the keyboard shortcuts, but once you master them, you will find yourself coding much faster without using a mouse between lines. If you save 30’ per day by using keyboard shortcuts, you can have 3.5 hours every week!

VSCode is my favorite IDE because of its useful keyboard shortcuts and extensions. I cover some of the extensions to view code and incorporate the best practices for Python**, **butI haven’t gone in-depth in keyboard shortcuts.

There are many keyboard shortcuts in VSCode and they might overwhelm you. In this article, I will narrow down to just my top 9 frequently used keyboard shortcuts.

If you find it a lot to remember, just write these keyboard shortcuts on a small sheet of paper and use it as a reminder when you learn these keyboard shortcuts. Even if you can learn 1 keyboard shortcut out of this article, that already helps you code much faster than not using any keyboard shortcut.

Basic Editing

Note:_ The keyboard shortcuts listed in this section can be used for different editors such as Medium or Word._

Expand the selection to the next or previous word

Instead of using the mouse to choose the specific text or using Shift + left to expand the selection to the next or previous character, it is faster to use **Shift + Ctrl + Left/Right **to expand the selection to the next or previous words.

Image for post

Select words from the current cursor to the end, or the beginning of the line

If you want to select words from the current cursor to the end of the line, you can use Shift + Ctrl + Left/Rightto expand the selection to the next or previous words like mentioned above, but there is a quicker way than that.

Use **Shift + End **like below to expand the selection from the current cursor to the end of the line.

Image for post

And to expand the selection from the current cursor to the beginning of the line, use Shift + Home.

#vscode #code #keyboard #data-science #keyboard-shortcuts

Fannie  Zemlak

Fannie Zemlak


Top VSCode keyboard shortcuts every developer should know

Here’s a list of some essential VSCode keyboard shortcuts that will save you at least a few minutes every day.

  • Move line up/down -_option + up/down_

  • Jump to Matching Brackets -_shift + command + \_

  • Replace next similar word -_option + command + f_

  • Copy line up/down -_shift + option + Up/Down_

  • Code Fold -_command + option + [_
  • Code Unfold -_command + option + ]_

  • Select next match -_command + d_

  • Deselect next match -_command + u_

  • Open and close sidebar -_command + b_

  • Add cursor above/below -command + option + up/down

  • Add multiple cursors -option + mouse click

  • Delete line -shift + command + k or command + delete

  • Open current file in finder/explorer -command + k then r

  • Zen Mode -_command k__ then __z_

  • Comment Code -command + /

  • Add cursor to all selected lines -shift + option + drag mouse

  • Split-screen -command + \
  • Toggle Split-screen horizontal and vertical views -command + option + o

Leave a clap or a few hundred claps :) if you like my list. If there is a shortcut that you use regularly and is not on the list, add it in the comments below.

#vscode-productivity #vscode #vscode-keyboard-shortcuts