Rack::Konami is a Rack middleware that injects a hidden snippet into your pages. When a user enters the Konami Code (↑ ↑ ↓ ↓ ← → ← → B A ↵), the snippet fades in and then disappears after a configurable delay.
- Works with jQuery 1.4 or later, falling back to vanilla JavaScript if jQuery isn't present.
- Supports both keyboard and touch devices.
- Configurable HTML snippet and fade-out delay.
- Automatically updates the
Content-Length
header when injecting content. - Compatible with Ruby 3 and Rack 3.
gem install rack_konami
require 'rack_konami'
use Rack::Konami, html: "<img src='/images/rails.png'>", delay: 1500
app = lambda do |env|
[200, { 'Content-Type' => 'text/html' }, '<html><body><p>Awesome Body</p></body></html>']
end
run app
Add to config/environment.rb
:
config.gem 'rack_konami'
config.middleware.use Rack::Konami, html: "<img src='/images/rails.png'>", delay: 1500
Add to your Gemfile
:
gem 'rack_konami'
Then in config.ru
:
use Rack::Konami, html: "<img src='/images/rails.png'>", delay: 1500
Add the gem to your Gemfile
and install:
gem 'rack_konami'
Then configure middleware in config/application.rb
(or an initializer):
config.middleware.use Rack::Konami, html: "<img src='/images/rails.png'>", delay: 1500
Open your browser and type ↑ ↑ ↓ ↓ ← → ← → B A ↵
.
bundle install
bundle exec rake test
- Fork the project.
- Make your feature addition or bug fix.
- Add tests so future changes don't break your code.
- Commit without modifying the Rakefile, version, or history.
- Send a pull request (topic branches are appreciated).
Copyright (c) 2010-2025 Mark Turner. See LICENSE for details.