├── CHANGELOG.md ├── sounds ├── laptop_notebook_key_press.mp3 ├── laptop_notebook_delete_key_press.mp3 ├── laptop_notebook_spacebar_press.mp3 └── laptop_notebook_return_or_enter_key_press.mp3 ├── menus └── mechanical-keyboard.cson ├── package.json ├── keymaps └── mechanical-keyboard.cson ├── lib ├── key-sound.coffee ├── mechanical-keyboard.coffee └── keyboard-listener.coffee ├── README.md ├── LICENSE.md └── spec └── mechanical-keyboard-spec.coffee /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.1.0 - First Release 2 | * Every feature added 3 | * Every bug fixed 4 | -------------------------------------------------------------------------------- /sounds/laptop_notebook_key_press.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/remanc/mechanical-keyboard/HEAD/sounds/laptop_notebook_key_press.mp3 -------------------------------------------------------------------------------- /sounds/laptop_notebook_delete_key_press.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/remanc/mechanical-keyboard/HEAD/sounds/laptop_notebook_delete_key_press.mp3 -------------------------------------------------------------------------------- /sounds/laptop_notebook_spacebar_press.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/remanc/mechanical-keyboard/HEAD/sounds/laptop_notebook_spacebar_press.mp3 -------------------------------------------------------------------------------- /sounds/laptop_notebook_return_or_enter_key_press.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/remanc/mechanical-keyboard/HEAD/sounds/laptop_notebook_return_or_enter_key_press.mp3 -------------------------------------------------------------------------------- /menus/mechanical-keyboard.cson: -------------------------------------------------------------------------------- 1 | # See https://atom.io/docs/latest/creating-a-package#menus for more details 2 | 'menu': [ 3 | { 4 | 'label': 'Packages' 5 | 'submenu': [ 6 | 'label': 'Mechanical Keyboard' 7 | 'submenu': [ 8 | { 'label': 'Toggle', 'command': 'mechanical-keyboard:toggle' } 9 | ] 10 | ] 11 | } 12 | ] 13 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mechanical-keyboard", 3 | "main": "./lib/mechanical-keyboard", 4 | "version": "0.1.0", 5 | "description": "Atom package to make mechanical keyboard noises while you type", 6 | "activationEvents": [ 7 | "mechanical-keyboard:toggle" 8 | ], 9 | "repository": "https://github.com/remanc/mechanical-keyboard", 10 | "license": "MIT", 11 | "engines": { 12 | "atom": ">0.50.0" 13 | }, 14 | "dependencies": {} 15 | } 16 | -------------------------------------------------------------------------------- /keymaps/mechanical-keyboard.cson: -------------------------------------------------------------------------------- 1 | # Keybindings require three things to be fully defined: A selector that is 2 | # matched against the focused element, the keystroke and the command to 3 | # execute. 4 | # 5 | # Below is a basic keybinding which registers on all platforms by applying to 6 | # the root workspace element. 7 | 8 | # For more detailed documentation see 9 | # https://atom.io/docs/latest/advanced/keymaps 10 | 'atom-workspace': 11 | 'ctrl-alt-m k': 'mechanical-keyboard:toggle' 12 | -------------------------------------------------------------------------------- /lib/key-sound.coffee: -------------------------------------------------------------------------------- 1 | VENDOR_DIR = __dirname + '/../sounds' 2 | NUM_BUFFERS = 10 3 | 4 | module.exports = 5 | class KeySound 6 | 7 | index: 0 8 | buffers: null 9 | 10 | # Need multiple buffers to handle keypresses that occur before a previous 11 | # keystroke of the same type has stopped playing 12 | constructor: (fileName) -> 13 | i = 0 14 | @buffers = while i++ < NUM_BUFFERS 15 | new Audio(VENDOR_DIR + '/' + fileName) 16 | 17 | play: -> 18 | @buffers[@index++ % NUM_BUFFERS].play() 19 | -------------------------------------------------------------------------------- /lib/mechanical-keyboard.coffee: -------------------------------------------------------------------------------- 1 | KeyboardListener = require './keyboard-listener' 2 | 3 | module.exports = 4 | 5 | toggleState: false 6 | keyboardListeners: null 7 | 8 | activate: (state) -> 9 | atom.workspaceView.command 'mechanical-keyboard:toggle', => @toggle() 10 | @keyboardListeners = []; 11 | atom.workspaceView.eachEditorView (editorView) => 12 | @keyboardListeners.push new KeyboardListener editorView 13 | 14 | toggle: -> 15 | @toggleState = !@toggleState 16 | if @toggleState 17 | @keyboardListeners.forEach (listener) -> listener.subscribe() 18 | else 19 | @keyboardListeners.forEach (listener) -> listener.unsubscribe() 20 | 21 | deactivate: -> 22 | # nothing to do here 23 | -------------------------------------------------------------------------------- /lib/keyboard-listener.coffee: -------------------------------------------------------------------------------- 1 | KeySound = require './key-sound' 2 | 3 | keyCode = 4 | DELETE: 8 5 | SPACEBAR: 32 6 | 7 | # Preload sounds here so they can be reused across editorViews. 8 | deleteKey = new KeySound('laptop_notebook_delete_key_press.mp3') 9 | spaceBarKey = new KeySound('laptop_notebook_spacebar_press.mp3') 10 | otherKey = new KeySound('laptop_notebook_return_or_enter_key_press.mp3') 11 | 12 | module.exports = 13 | class KeyboardListener 14 | 15 | constructor: (editorView) -> 16 | @editorView = editorView 17 | 18 | subscribe: -> 19 | @editorView.on 'keydown.mechanicalkeyboard', (e) -> 20 | keySound = switch e.which 21 | when keyCode.DELETE then deleteKey 22 | when keyCode.SPACEBAR then spaceBarKey 23 | else otherKey 24 | keySound.play() 25 | 26 | unsubscribe: -> 27 | @editorView.off 'keydown.mechanicalkeyboard' 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # mechanical-keyboard package 2 | 3 | Coworkers complaining that your [cherry blues](http://deskthority.net/wiki/Cherry_MX_Blue) are too loud? Or maybe you're just curious what all the hype is about? 4 | 5 | Type like a **pro** with this atom package - it will make mechanical keyboard noises when you type. 6 | 7 | # Usage 8 | 9 | By default, the toggle switch is bound to `ctrl+alt-m k`. Toggle it on - whoa! Toggle it off - well, you're back to where you began. 10 | 11 | **Note** That's a two step key activation - `ctrl+alt+m` and then `k`. 12 | 13 | Alternatively, you can use the menu item that's found in the Packages Menu: `Packages->Mechanical Keyboard->Toggle` 14 | 15 | # Credit 16 | 17 | All credit goes to the original mechanical keyboard project: 18 | - https://mechkey.herokuapp.com/ 19 | - https://github.com/rewonc/mechkey 20 | 21 | Sounds were sourced from freesfx.co.uk: 22 | - http://www.freesfx.co.uk 23 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /spec/mechanical-keyboard-spec.coffee: -------------------------------------------------------------------------------- 1 | {WorkspaceView} = require 'atom' 2 | MechanicalKeyboard = require '../lib/mechanical-keyboard' 3 | 4 | # Use the command `window:run-package-specs` (cmd-alt-ctrl-p) to run specs. 5 | # 6 | # To run a specific `it` or `describe` block add an `f` to the front (e.g. `fit` 7 | # or `fdescribe`). Remove the `f` to unfocus the block. 8 | 9 | describe "MechanicalKeyboard", -> 10 | activationPromise = null 11 | 12 | beforeEach -> 13 | atom.workspaceView = new WorkspaceView 14 | activationPromise = atom.packages.activatePackage('mechanical-keyboard') 15 | 16 | describe "when the mechanical-keyboard:toggle event is triggered", -> 17 | it "attaches and then detaches the view", -> 18 | expect(atom.workspaceView.find('.mechanical-keyboard')).not.toExist() 19 | 20 | # This is an activation event, triggering it will cause the package to be 21 | # activated. 22 | atom.workspaceView.trigger 'mechanical-keyboard:toggle' 23 | 24 | waitsForPromise -> 25 | activationPromise 26 | 27 | runs -> 28 | expect(atom.workspaceView.find('.mechanical-keyboard')).toExist() 29 | atom.workspaceView.trigger 'mechanical-keyboard:toggle' 30 | expect(atom.workspaceView.find('.mechanical-keyboard')).not.toExist() 31 | --------------------------------------------------------------------------------