How can I listen for keypress event on the whole page?

I would use @HostListener decorator within your component: import { HostListener } from ‘@angular/core’; @Component({ … }) export class AppComponent { @HostListener(‘document:keypress’, [‘$event’]) handleKeyboardEvent(event: KeyboardEvent) { this.key = event.key; } } There are also other options like: host property within @Component decorator Angular recommends using @HostListener decorator over host property https://angular.io/guide/styleguide#style-06-03 @Component({ … host: { … Read more

Xcode duplicate line

Go to this folder which contains dark side of the force: Xcode 4.2 or prior: /Developer/Library/PrivateFrameworks/IDEKit.framework/Resources Xcode 4.3 or later: /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Resources. Open IDETextKeyBindingSet.plist. Add a new dictionary and a new command item as the screenshot below (name them what you want): That’s: selectLine:, copy:, moveToEndOfLine:, insertNewline:, paste:, deleteBackward: Restart Xcode and go to Preferences – … Read more

How to select all instances of a variable and edit variable name in Sublime

Put the cursor in the variable. Note: the key is to start with an empty selection. Don’t highlight; just put your cursor there. Press ⌘D as needed. Not on a Mac? Use CtrlD. Didn’t work? Try again, making sure to start with nothing selected. More commands: Find All: Ctrl⌘G selects all occurences at once. Not … Read more

File not found.