Skip to content
1 change: 1 addition & 0 deletions app/dependencies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
require 'browser/http'
require 'browser/location'
require 'browser/history'
require 'browser/navigator'
13 changes: 13 additions & 0 deletions app/helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require 'dependencies'

class Helper
@@navigator = $window.navigator

def self.ios?
@@navigator.user_agent&.match?(/\b(iPad|iPhone|iPod)\b/) || false
end

def self.macos?
@@navigator.user_agent&.match?(/\bMac\b/) || false
end
end
4 changes: 3 additions & 1 deletion app/try_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require 'editor'
require 'lesson'
require 'ruby_engine'
require 'helper'

# The TryRuby application
class TryRuby
Expand Down Expand Up @@ -61,7 +62,8 @@ def initialize

#If hold down the control and the Enter key goes down, run
$document.on :keydown, '#editor' do |e|
if e.key == "Enter" && e.ctrl?
if (e.key == "Enter" && (e.ctrl? && !Helper.ios?)) || ((Helper.macos? || Helper.ios?) && e.meta?)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right-hand side of the || expression is missing check for Enter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for pointing this out. I've fixed the issue, please check it out.

e.prevent
do_run
end
end
Expand Down
Loading